Showing posts with label sd/mmc. Show all posts
Showing posts with label sd/mmc. Show all posts

Thursday, November 12, 2037

About the projects // О проектах

68k project (under construction)
Idea:here
Read by tag:68kavr

Z80 project (considered complete, but will be updated sometimes)
Idea here
Read about Searle Grant's SBC SD interface (and generally CP/M SD implementation) by tag sgsbcsd

Note, that the early records were imported from Livejournal and should be edited by me sometimes later (I bet that will never happen).
Also, some early records may contain some weird letters - that's russian, but it is always translated, do not be afraid.
Also, sometimes I write about some unrelated (even PC!) but weird hardware, some unrelated but weird network technologies, and some weird things. May be even I'll attempt to write a big post about butterflies. If I ever got interested in butterflies.

Monday, June 8, 2015

68kavr ver 2560/0.00.02 is out

If anyone cares, I've updated my 68kavr firmware and BIOS. Lots of changes, but I'm lazy to build a normal release (because of summer) so this release is incremental. And, it is numbered 0.00.02!

Friday, September 5, 2014

Some more news on SGSBCSD

Looks like I have the code working with SDHC. I'll test in in a few days and release 0.00.04/2491.
So my future plans to port it to m68k code and update 68kavr project. UPD: 2491 version of Searle Grant SBC SD interface released. It works!

Wednesday, September 3, 2014

Huge SGSBCSD update - 2490

A lot of bug fixes for my SD interface for Searle Grant's SBC. A loot! If anyone have it installed - update it now

Wednesday, April 9, 2014

68k project: step 6 - lets' start thinking about CP/M

First, some news of the project: The updated scheme HERE . Generally nothing new, only MAX232A is drawn
Here is the picture of my board taken 20140325.
First, I have some minor (but nice!) changes in my firmware. First is
GOaddressmonitor command , which goes to the specified address.
And the second... (have I ever told you I'm genius? REALLY? Oh, sorry) - I catch the BREAK from a serial line and inititate CPU Reset! (actually, even MCU reset).
So, in C-Kermit> (if you use C-Kermit as do I) 's terminal mode, I can press [CTRL]+[\] [B] , and get a reset!
More, I own an HP 9000 A500 server and it has as "Service Processor". And I'd like to have a full Service Processor console in future like the one on that server. Saying, it can turn on and off ATX power (if I have a spare pin and free memory on Atmega8)....
Sometimes in future
So, let's talk about CP/M iteself
This is my first attempt to port CP/M to any computer by the method explained in, our case, "System Guide". The prerequestings are:
  • I should have System Guide (I do)
  • I should have CP/M 68 in S-records (I do from http://www.cpm.z80.de/binary.html : I use this)
  • The system must accept S-Records (my does)
  • I must have an assembler which generates S-Records (I use A68k from TI 68K calculator project:
    
    68000 Assembler - version 2.71.F3s (Sep 21, 2004)
    Copyright 1985 by Brian R. Anderson
    AmigaDOS conversion copyright 1991 by Charlie Gibbs.
    Adapted for use with Fargo by David Ellsworth.
    Bugfixes and additions by Julien Muchembled, Paul Froissart and Kevin Kofler
    
    
    Warning: do not use asm68k
    
    asmx multi-assembler version 2.0b5
    Copyright 1998-2007 Bruce Tomlin
    
    
    buggy as shit. May be vasm is good - but I'm not ready to write linker scripts just to get SRecord from the source with static lables and given ORG)
So, on the CP/M distribution there is a file CPM15000.SR - that's an CP/M in S-Records (which is loaded from address $15000).
On the first disk of distribution set there is a very useful README.TXT which says that to create a BIOS I should figure out _init (== ORG of BIOS == $1B000) and _ccp ($150BC) symbols in CPM15000.MAP (and that differs from what is written in "System Guide"; there said you should patch Srecords file [for 1.0 and 1.1 CP/M 68k vers.]).
So lets go to "System Guide" directly to the Appendix B on page 59 and start type "Sample Bios" into text editor.
As you can see, BIOS install TRAP #3 and CP/M works with BIOS via this TRAP. I've tried to start with
  • constat
  • conin
  • conout
, but it was not enough; setexc also a must for CP/M to show you it's A:>. The first thing it does, it installs an TRAP handlers for almost all the TRAPS! I will not retype it here, that will be attached later, when it will be at least read/write sectors. To start CP/M first load CP/M itself, then BIOS, then type go15000
After I wrote basic sector read/write access I was able to say DIR,TYPE and even REN. But could not run any program, that's because I've forgot getseg call at all. And then I was able to run DDT68000, but during read it compained "Cannot write sector" (and it was not writing sector at all!)
That was because I forgot flush call.
Funny - this code contains *No* CP/M specific code yet, and is just update of firmware ;-) Code for ChVI

Thursday, March 20, 2014

68k project: step 5 - SD interface


  The idea of SD interface is just an adoptation of my SD interface for Searle's Grant SBC. So go there for SD card pinout,resistor values, 3.3V power, etc. The only change is 2*7474 to one 74175. Or you can use 2*7474. Or any latch of this sort.
  Some notes: a rewiring /AC0000,CPURESET->SETAVRCLK, FCE,AVRCE->MIXEDCLK2 on the scheme is not significant at all and is here just to correspond my actual wiring.
    As for SD interface, it consists of a 74175 trigger for data output and 7403 as data input. To write to 74175 we mix /A80000 line with /MEMWR and /DS (on an extra 7432) and latch D0-D2 to the trigger, so that are SD card's Clock (SDCLK), DataIn (SDDATAIN) and Chip Select (SCCS) [why SCCS? Rename it to SDSC later] SPI lines. They should be mixed via resistors to get 3.3V-alike signals (again, see this). Do not forget that SD card itself should be feed with +2.8 - +3.3V so you can use 7833 or just a LED to drop the voltage.
   For data in, we mix /A80000 line with /MEMRD and /DS to get /80000RD and invert it to get 80000RD. Passed throw 7403 (with SDDATAOUT) we direct this open-collecor output to D0. So this output is low only when 80000RD is active (high) and SDDATAOUT is high too, so this is inverted input. So, from 68k side we can

    move.b #7,$80000 ; CS - up, Dataout - up, CLK - up
    move.b #2,$80000 ; CS - down, Dataout - up, CLK - down


manage that bits this way (but better keep higher bits high - we may have some extra SPI devices in future), and to read it just read lower bit from $80000 and invert it.

Just to remind:
D0 - CLK
D1 - DATAOUT
D2 - CS
D3 and D4-D7 - reserved for future SPI devices (who knows which? extra Atmega, RTC, etc)

   The Code for ChV can detect (command "BOOT") the card (CMD0), can send it CMD1 for (doing smth usefull), some command to ensure the card's sector size is 512 bytes, but nothing more still. (I use this and this) as reference)
  Also, scince now I use Atmega's PC5 pin for CTS. That's because I've tried to cut-and-paste CP/M-68 S-record files and was unable to do that without hardware flow. So in AVR code there is a #define WITH_CTS to use this code (enabled by default) and 256 bytes ring boofer for handling input bytes from serial.
  As you could note, there is a sort-of-monitor program included in 68k asm Currently it can:
BF Blink SDCLK fast (with fullspeed clock)
BS Blink SDCLK slow (with AVRCLK)
BLINK Blink until key pressed (fullspeed clock)
ON Set SDCLK to 0 (or 1)
OFF Set SDCLK to 0 (or 1)
1 Set SDCLK to 1, SDDATAIN to 0, SCCS to 0)
2 Set SDCLK to 0, SDDATAIN to 1, SCCS to 0)
4 Set SDCLK to 0, SDDATAIN to 0, SCCS to 1)
IN Tell SDDATAOUT status (or inverted SDDATAOUT?)
DUMP[optional address] Dump memory from address (or continue to dump from that address if no address given)
BOOT Try to init the SD card
S[srecord] Parce S-Records. It understands S1,S2,S3 records and ignores all the others

It's easy to extend this command set:
first, write an f_myfunc subrotine which should return to monotor with rts. Then add it's mnemonic to commands: and it's address (f_myfunc) to commands_vector When called, A1 will point to the first byte after you's command mnemonic in input buffer, so if was called as
myfuncbebebe
, A1 will point to "bebebe"
  :Also there is one more thing I want to warn you: I use ISP programming of ATmega via SCLK/MOSI/MISO/RESET pins of ATmega, AND THIS IS UNRELATED TO SPI BUS WE'VE JUST DISCUSSED!
  : Be careful: I've burned 3 Atmega's while ISP programming it until I installed a RESET switch for CPU (RESET+HALT)
So to make an ISP firmware update, hold down RESET+HALT of CPU, then do firmware update (I use avrdude and usbasp)

Tuesday, April 23, 2013

Found one more SD card not working

Sandisk SDSB002G B35. Enters SPI mode, but unable to reset. Going to dig this out.
So it extends the list of known not working cards which consisted of a single record Toshiba SD-M16

Known working:
Apacher AP1GSD60
Kingston SK4112-966A001F

Searle Grant's BIOS v1.0 and IOBYTE

Yesturday I've found that at Jan '13 Searle Grant released BIOS v 1.0 with IOBYTE support. And more - that my SGSBCSD is based on previous version. So today I've synced my code and v 1.0 and got something which will be named sgsbcsd2340 or 2350. I have a working code, but I have to ensure it works stable.

Saturday, April 13, 2013

Some unrelarted idea of booting IBM PC compatible

..using SD card attached to printer port:
Imagine you have some old 86/88+ IBM PC. You probably do not have floppy drive (or unwilling to use it). Here is the idea how to boot it/use it.
Attach SD to printer port somehow according SPI.
Take an Network card (or any other) with ROM socket. Write an BIOS extension with loader which will boot from LPT/SPI and plug it into that socket.
Sure, CP/M 86 can be booted this way, and, with modification of CP/M BIOS (which must be located in the boot SD card) it will run.
More, I bet this also can be done with Linux/xBSD and 386+ (but I havent seen SD card support over printer port in kernel; strange, that's a clear idea, why does not it exist?) and some hacking of lilo or other loader.

It's really unclear am I the first man who thought about it or what?
What all the other hummanity is thinking about? World crisis? Gay marriage? North Korea nuclear bomb? (I do not mind if this will not affect RAM prices)
Where to send notification I will accept a Nobel prise or two?
UPD: about the second one. This idea may be extended to OpenFirmware computers (Suns, Power-based Macs, RS/6000,what else?) - in this case you do not need and bios extension, cause it should be much easy to write an OF/Forth loader.
Definitely, two Nobel prises, not less!

UPD: 130414 this Indian Guy implemented an Parralel Printer Port/SPI kernel driver for linux. I'll try it.


Интересно почему никому не приходило в голову бутить писюк методом втыкания в него какой-нибудь карточки с дыркой под boot-rom (например, сетевухи), засовывания в нее прошивки которая бутила бы систему с SD карточки, засунутой в принтерный порт по SPI?

Хакануть CP/M 86 BIOS по моему опыту дело на пару вечеров (ну, не считая того что я не знаю 86ого асма), но ведь небось на трешке (386) так и Linux поднять как нефиг ссать?

Интересно почему в Linux нет драйвера работы с SDшкой через LPT порт?
Интересно мне первому эта идея в голову пришла?
О чем, блядь, думает прогрессивное человечество? О топоте котов?
Где блядь Нобелевку дают? Дайте две!
UPD: кстати, о второй. Берем любую тачу с OpenFirmware (Sun, PowerMac, RS/6000) и цинично лабаем этот лоадер на форте. Это вообще как два байта переслать.
Точняк, меньше двух нобелевок не предлагать!

Sunday, February 24, 2013

Some notes on accessing track 0 on SGSBCSD

Well, I've told that C000h TPA (strictly speaking, not TPA, but start of CCP) based CP/M image starts from track 0 / sector 0, the C200h system should start from SD offset 200h - i.e. track 0 / sector 1,D000h TPA - from track 0 / sector 8 That leads to a significant problem: everything works until you do not try to rewrite/regenerate CP/M itself inside of SBC, because the changes will we written to track 0 / sector 0 which will led to unusable boot image. So, if you want to do system change inside of SBC - use C000h based systems for now. In future I plan to change the algorythm of accessing track 0. Saying we have C800h TPA system starting from sector 4 and trying to write track 0/sector 0. I will add 4 to sector number so you'll access sector 4 as expected. That will lead to the situation you will not be able to access track 0 sector 0-3 at all. I think this is not a significant loss.

Tuesday, February 5, 2013

Bugfix release 2322

I had an awfull error writing sector. I waited just 255 times for non-zero byte after SD_CMD24 command.
It was wrong. Now I wait for FFFF ticks max - that works with my Apacer 1G card.

I hope next weekend I'll go to the Mitino market and buy a pocket of the most strange SD and MMC cards to test.
The release, as usually, here

UPD: I've attached c-kermit (version 2.2/IOBYTE) on the disk image inside of distribution. And it's even possible to transmit something.
On the CP/M side, tell kermit
set port tty
On unix side, tell your local kermit
set streaming off
and something somehows transmits, but with a huge number of errors. That's a topic to be explored.

Saturday, February 2, 2013

Monday, January 28, 2013

Searle Grant's SBC and SD - current status

I have good news. I've implemented read sector, write sector and looks like things work. I haven't implemented reload CCP yet, but this is just a question of time and work - everything is clear for me, currently I have to reload CCP by full reload. Not so good news. TPA will be as low as 48K for the first public version. Only SD (up to 2GB) and MMC will be supported (MMC is unclear; I do not have one, but it should) - I mean no SDHC and SDXC support, bit I think at least SDHC will be added soon. The initial loader will be distributed in .HEX file to be load from terminal from $5000; ROM image - in the nearest future (but after SDHC code)

Sunday, January 13, 2013

Searle Grant's SBC - lets boot from SD

That's easy


Это просто

First, assemble a scheme I described here .
Next, get the file.
Then, let's write something to SD card, saying

org $D000 ; this is the place program will load from the card - do not be confused with $5000!
start:
ld a,'*'
rst 8
jp start
org $FFFE
db $00,$0D ; this is a jump vector address

Assemble, move it to sd card the way ld a,'*' will be the first two bytes, and 00 0D should locate at 2FFE offset.
Under linux, dd is your's friend.
And - type test.out into terminal window and run it by G5000.
You should see how the card is booted and get a lot of *'s.
Warning: the program (loader) generates a HUGE debug info.


Собираем это .
Берем файлец .
Далее, напишем что-нибудь на SD карту, например

org $D000 ; это куда мы будем грузить с карты
start:
ld a,'*'
rst 8
jp start
org $FFFE
db $00,$0D ; это собственно ровно вектор куда прыгать

Ассемблите, пишите на SDшку так что ld a,'*' будут двумя первыми байтами, а 00 0D должны находиться по оффсету 2FFE.
Под linux это делается командой dd.
Далее грузим из терминала test.out и запускаем его командой G5000.
Далее будет видно как оно будет грузится (там КУУУУЧА дебага) и потом должны увидеть кучку звездочек.

Sunday, January 6, 2013

Searle Grant's SBC - lets start with SD

I tried. Trust me, I tried.
But I am unable to make CF interface to work properly.
So I started to implement fn SD interface


Я честно старался, но опять нихуя не вышло!
Короче CF интерефейс компа Searle Grantа у меня нормально не работает, поэтому я решил начать имплементить SD.

The Idea: lets' try to build it.
The Scheme:

The software: here
The results: at least, CF answers properly to "GO IDLE STATE" command
The note: by a strange reason, Z84C0006 (CMOS one) does not hear open collector (yes, inverted) input (at least in my cheme), SHARP LH0080A does. At least for now. And I use 1K resistors instead of 680 ohm resistors - I have no 680 resistors around.
Testing it all:
Plug off SD/MMC, load basic, say
OUT 16,0
check zeroes on triggers.
Repeat OUT 16,7 and OUT 16, anything and check for triggers
Then, shorten data out line to ground and
PRINT INP(16)
Lower bit should be 1 (this is an inverted data)
Leave data NC or plug it somewhere to +5 and repeat, you should get lower bit 0.
If it does not, change CMOS CPU to NMOS.... At least that's what I do for now, that's weird, but I'll think about it later.

As for CF interface, yes, it was very hard to solder it, and ONCE it even loaded, but I mostly got a strange hang after reading sector $38 (I wrote a debug program showing me how does it loads). I've tried to change all the logic chips to HCT, make my wires shorter - same result.

UPD 20130108: The purpose of the led (that should be a RED led) is to drop voltage from +5 to somewhere from +2.8 to 3.3. I saw this recipe in inet, but I do not remember where. Note: before CS goes down, this led will not be turned on.
Keep in mind I run SBC at 2.7 Mhz // 38400 baud, I do not know if this is significant for now
UPD 20130108.2: That's a proper scheme! I'm able to read 512 block from an SD card, but that will be in the other post
UPD 20130114: Install 8 pullup resistors on data bus (4.7k to 5). That's a right idea. After that, Z84C00 works.


Схема:

Софт: тут
Результат: как минимум, CF загоняется в SPI mode командой "GO IDLE STATE" и отвечает правильно
Соображения: Какого то хуя Z84C0006 не слышит моего (да-да, инвертированного) открытого коллектора, а вот SHARP LH0080A - легко и непринудженно. Как минимум в ходе текущих исследований. А, еще я сунул 1k резисторы вместо 680, у меня их прям щаз нет.
Тестирование:
Не суйте СFку, грузаните BASIC, пишите
OUT 16,0
На выходах триггеров ясный пень должны быть нули.
Суньте туда вместо нулей 255, 7 или еще чего-нибудь и посмотрите что там на триггерах.
Теперь закоротите data out (у нас инверсный вход),
PRINT INP(16)
должен в младшем бите показать 1. Выдерните или коротните на +5 - в младшем бите должен быть 0.
Если ничего не получается - поменяйте проц на nmosный, старье какое-нибудь. Ну во всяком случае я сейчас так делаю, потом подумаю как делать не так.

А CFка не работает следующим образом. Кроме того что я заебался ее распаивать, (и, кстати, разочек она так таки загрузилась), она стабильно виснет при чтении сектора $38. Я налабал программку с дебагом чтобы она показывала что она делает - так вот, она показывает именно это. Я менял все чипы на HCTшные, делал провода короткими насколько можно - хуев мне лукошко, а не работающий CF.

UPD 20130108: Светодиод на power линии - это не просто так светодиод (он обязан быть красным), эта штука жрет так чтобы на CFке оказалось от +2.8 до +3.3. Это я спер [как собственно и 90% всего что я делаю] у каких-то чуваков в сети, но забыл где. Кстати, пока не переведете CS вниз, то оно ничего и не жрет.
Еще кстати - я на 2.7Mhz // 38400, не уверен что это все не будет работать на 7Mhz, проверю - отпишу.

UPD 20130108.2: Схема кстати правильная - я смог прочитать блок из 512 байт с SDшки. Но об этом - в следущем посте.
UPD 20130114: 8 резисторов дата - 4.7k - +5 - очень правильная идея. Z84C00 после этого заработал в этой схеме.