Cumulus Firware Compilation

This is the right place to discuss on how to implement hardware vsync, adding a VIA or AY chipset, puting multiple roms, or how to design a new flash expansion card.
Godzil
Squad Leader
Posts: 733
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Cumulus Firware Compilation

Post by Godzil » Tue Jan 20, 2015 12:55 pm

Chema wrote:Another thing is about communicating from the Oric to the Cumulus. The FD179x has 11 different commands. It is possible to use any invalid command to broaden the possibilities. For instance any command whose bits are 11111xxx is invalid. It is possible, therefor, to implement extended behaviour in the Cumulus by creating new commands. Whenever a new command is detected, the track and/or sector registers may be used to indicate extra information.

This way it could be possible to implement commands on the Oric side which could ask the Cumulus to send the directory information, select a disk image, mount it, reset, etc. I am sure you can imagine the possibilities... even a whole new OS.

But yeah, it would only be compatibe with Cumulus and I am not sure about the amount of memory that it would require on the PIC.

I still think this is an interesting project, but it is complex. In fact we have not found a solution to store tape based games on disk (at least not all). A program which loads a memory dump created with an emulator and stored in a disk file into the Oric would be much more practical. And it could be done with the Cumulus as it is and would be compatible with Microdisc too.

As I said, just some random thoughts...
If we really want to do something like this, using the same protocol as the HxC remote and harddisk mode would be preferable, as some people use the HxC with a real FDC and making tools would benefit every one, not only peoples with Cumulus.

For the other parts, I'll need some time, but I will definitely take a look at the source code.

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Tue Jan 20, 2015 1:35 pm

Godzil wrote: If we really want to do something like this, using the same protocol as the HxC remote and harddisk mode would be preferable, as some people use the HxC with a real FDC and making tools would benefit every one, not only peoples with Cumulus.

For the other parts, I'll need some time, but I will definitely take a look at the source code.
You mean this spec? Sure it could be done. It would require more code and work on the Oric's side, but it would be compatible with Microdisc+HxC.

On the negative side, I am not sure how this mode works on HxC but surely there is much more potential in creating new commands for the Cumulus as you can manage the device itself (reset, change mode,...).

Anyway, not a project I might jump in for the time being... but all this info is good as reference for those interested :)

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Tue Jan 20, 2015 3:06 pm

Another point I found. This time dealing with initializing the SD card in SPI mode. The process seems correct and should detect both SDHC and SD cards. However when initializing the code is:

Code: Select all

	/* Send CMD0 */
	if (card_command(0x40, 0x0000, 0x0000, 0x95) != 0x01) 
		return 0;
which does not make a loop to wait for a response as it should do (from what I read). See this example code I found (commands have always the bit 6 set; here command 0 is the same as command $40 above):

Code: Select all

    command(0, 0, 0x95);
    count = 0;
    while ((readdata != 1) && (count < 1000)) {
        spi_read();
        count++;
    }
This is the only place in the firmware code where there is not such a loop (other commands need to be resent along with the waiting loop; some examples even try the above code a number of times, thus resending/waiting/if error resending/waiting...).

I am not sure if this could point out the reason why SD cards are not supported, maybe it takes longer for them to answer the command (?).

BTW the bootloader code does not wait for this and other commands either.

Godzil
Squad Leader
Posts: 733
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Cumulus Firware Compilation

Post by Godzil » Tue Jan 20, 2015 5:01 pm

Chema: Good point, this will need investigation :)

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Tue Jan 20, 2015 7:49 pm

Okay, lately I am a bit thick or is it just bad luck.

I tried a first firmware compilation today. Everything seemed perfect, same CUMULUS.BIN file as the original for my display. Then I took my SDHC card (which I've been using) formatted it and copied the firmware. Update process seemed successfull. Cumulus booted perfectly but alas SD Card I/O Error.

I went back to my PC restored all my dsk files, tried again... SD Card I/O Error.

Flashed the original firmware and still the same error...

What did I do wrong when formatting the card? Anyone? I used the default parameters from WinXP (FAT32) :(

User avatar
iss
Flight Lieutenant
Posts: 430
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Cumulus Firware Compilation

Post by iss » Tue Jan 20, 2015 8:43 pm

Hi Chema,
you can try to format your SD Card with "HP USB Disk Storage Format Tool".
Here is link to it on 3rd party site: http://hp-usb-disk-storage-format-tool. ... ormer.com/
Or you can g00gle for above string.
This formatter creates MBR on USB-sticks and SD-Cards which is OK for all OS's.
IMO, this is what Cumulus expects to find in sector #0, or at least it works for me!
Hope this will help.

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Tue Jan 20, 2015 11:01 pm

After spending hours trying to find the HP USB Disk Storage/Format tool I found it, but could not make it work. The dialog displays with all the boxes and options grayed out (?).

I am trying to find another tool for SD formatting. This could be the problem indeed, because the card worked perfectly until I formatted it from Windows (need a fresh-formatted SD with the CUMULUS.BIN file). Not sure how others may have done this...

Cumulus recognizes the card and is able to update the firmware because it does not look at the MBR or FAT or any table; I guess it gets the file from an specific sector or something like that. When I boot cumulus for normal operation it seems to not be able to get the directory.

But that is just a guess...

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Tue Jan 20, 2015 11:43 pm

Well the good news is I installed this tool https://www.sdcard.org/downloads/formatter_4/index.html and it worked! My SDHC card is back!

The bad news is I patched the firmware to wait a bit for the result of COMMAND 00 and it did not change the behaviour with the old SD card: still I/O Error. This issue needs more investigation :)

Probably a good idea is trying to put some debug messages to determine what is going wrong (where the sd_init is returning 0, because I think that is where the problem lies... but I might be wrong). But debugging is not a quick process... patch fw/prepare SDHC card/update cumulus/reboot/test SD card...

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Thu Jan 22, 2015 12:18 am

I tried to pursue where the code was failing with SD cards and it is not (at least now) in the initialization of the card. The card_read function, which uses command 17 ($51 with 6th bit set), seems also correct.

It happens to give an error when calling fat32_dir_next or fat32_ini. One of my SD cards fail in the first routine, and the other in the second...

Of course both read data from the SD card, but assuming the error is not there (for now) and that we have correctly determined the type of card in the initialization process (something I want to make sure of) then the problem must be somewhat related to the FAT code.

In the fat32_init routine the sector 0 is read and interpreted. If something like the bytes per sector or the cluster size is wrong, it will fail. As only a very old SD card which already gave me some problems fails here, I will leave this for now.

In the fat32_dir_next routine the error seems to be produced by the call card_read(sector, fat32_sector_buffer); with the sector to be read. As I see nothing strange in the implementation of card_read, I will try to see if I can dump the sector number when the routine fails.... just in case the FAT code is doing strange things and it ends up asking for inexistant sectors.

So no success yet. I am learning a lot about SPI protocol for interfacing with SD cards :) but the problem is still lurking around...

Godzil
Squad Leader
Posts: 733
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Cumulus Firware Compilation

Post by Godzil » Thu Jan 22, 2015 10:44 am

Can you make a test by not trying to read the FAT but dumping the first 512 bytes of the SD card? I mean that instead or doing what it normaly should, read all of the MBR entry, then compare with what you will read on your PC with an hexeditor.

I suspect a more "stupid" bug in SD management (not the fat driver)

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Thu Jan 22, 2015 8:52 pm

@Godzil, it is not as easy as it sounds as I'd have to dump all the values to the Cumulus screen, which is not inmediate (though could be done); then I need a way to dump the same info from the SD card from Windows, which is something I don't know how to do.

However I traced the error up to a specific point. Both my old 128MB and 1GB SD cards are detected correctly as SD cards, and are initialized correctly. I already had problems with the smallest one, so I am not surprised that it fails when trying to read sector 0 (though it seems I can use it in Windows, anyway).

The interesting thing is what happens with the second one. Even when formatted as FAT16 (my utility doesn't let me choose anything different for SD cards :( ) it detects the card correctly, initializes it and reads sector 0. Cumulus also detects an MBR and finds the number of bytes per sector to be equal to 512 as it should (offset 11 in the read buffer).

However, when it tries to read the number of sectors per cluster it seems it is less than 16, so this check fails:

Code: Select all

	sectors_per_cluster = fat32_sector_buffer[13];

	if (sectors_per_cluster < 16)
            return 0;
        
I might try to modify (again) the firmware to also print this value, but anyone has a clue why this is happening?

User avatar
iss
Flight Lieutenant
Posts: 430
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Cumulus Firware Compilation

Post by iss » Thu Jan 22, 2015 9:29 pm

IMO, the proper and only working combination with Cumulus is:
- HC SDCard
- with MBR
- fat32 formatted
any other variant fails by me.
So, Chema, after you formated the card with your utility (this is to create MBR) than you can use Windows format to make it fat32, this will not break the MBR layout.

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Thu Jan 22, 2015 11:33 pm

iss wrote:IMO, the proper and only working combination with Cumulus is:
- HC SDCard
- with MBR
- fat32 formatted
any other variant fails by me.
So, Chema, after you formated the card with your utility (this is to create MBR) than you can use Windows format to make it fat32, this will not break the MBR layout.
That is exactly the problem. The code in the firmware seems to be written to support non HC cards, with no MBR and (not sure about this) FAT16.

But obviously it doesn't work.

Any ideas?

Godzil
Squad Leader
Posts: 733
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Cumulus Firware Compilation

Post by Godzil » Fri Jan 23, 2015 11:04 am

Chema wrote:
iss wrote:IMO, the proper and only working combination with Cumulus is:
- HC SDCard
- with MBR
- fat32 formatted
any other variant fails by me.
So, Chema, after you formated the card with your utility (this is to create MBR) than you can use Windows format to make it fat32, this will not break the MBR layout.
That is exactly the problem. The code in the firmware seems to be written to support non HC cards, with no MBR and (not sure about this) FAT16.

But obviously it doesn't work.

Any ideas?
If the code make assumption that non HC card does not have MBR and are formatted as FAT16, so the code is broken. HC and non HC is independent of the partitioning which is also independent of the file system..

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Cumulus Firware Compilation

Post by Chema » Fri Jan 23, 2015 11:47 am

@Godzil no, no... I meant that it checks for all the conditions. It should support nonHC cards with FAT16 or FAT32 and with and without MBR.

However I am not sure of anything anymore... Of course there could be an issue when reading a full 512 byte sector from the card which ends up reading garbage.

I will try to dump the read buffer information in the cumulus screen whenever an error occurs. I checked my card on my PC using a couple of tools I found, and the size should be 32, not less than 16.

So need more testing :(

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests