sdcard format script

36 views
Skip to first unread message

Ben-401

unread,
Sep 5, 2016, 12:52:33 AM9/5/16
to C65GS Development
we want a script that formats the sdcard, to work across different systems including Linux, Windows/Cygwin, Mac, and emulators etc.

i have updated the set script at
https://github.com/MEGA65/mega65-core/blob/mvfile/src/utilities/setsdcardinfo.sh
to auto-find the name of the device node.

works on linux under my setup, Can you please confirm that it works on your setup?
Also please feel free to modify to make it work your side, without breaking workability on my side.

i think its important we learn how to make code that works across systems.

Thanks to Gabor in
https://groups.google.com/d/msg/c65gs-development/lfTTbbDhWgo/d4pYs2__AAAJ
for pointing this out...

Ben-401

unread,
Sep 5, 2016, 12:55:36 AM9/5/16
to C65GS Development
once the 'set'-script is confirmed to get the right node-name, then the 'get'-script can be updated.

LGB Gábor Lénárt

unread,
Sep 5, 2016, 6:26:03 AM9/5/16
to C65GS Development
Hi,

It worked for me, on Linux (so at least it's a confirmation from me now, that it works, with the "asking fdisk on the partition node" theory), though I noticed some little issues, I've already posted and you seem to be noted :) Looking on the script I have some things I would do other way, but forget that, it's just cosmetic and nothing about the functionality, it's maybe my own taste only and professional work background dealing with also scripts since two decades among others.

But, what is more important to ask: is the result card (prepared with your script) works for real on an M65, can you confirm that? My stupid problem (sorry, I've bothered you in private mail too, maybe it's better for me to learn to use the "community channels", eg this group) that I have got "only" my own software M65 emulator not a "real M65" (ie in FPGA). Or a short of that at least. I've prepared a real SD card (with your script), and used by my emulator that way, via the /dev/... node. However I always have problem, eg on SYS49152 disk chooser in C64 mode stuck in hypervisor read_dir after the last valid directory entry. After that point it just tries again and again stepping over sectors and finally it hit an invalid read (ie reading beyond the end of the card device itself). I'm really not sure if it's fault of my emulation (though kickstart is able to "boot" into C65 mode from the card I've set up with your script in my emulator!) or some other issue with the filesystem (FAT fs creation parameters, root directory size, whatever) or kickstart/hypervisor DOS itself. Do you have any opinion on this? Thanks in advance!

Ben-401

unread,
Sep 5, 2016, 8:54:52 AM9/5/16
to C65GS Development
hi,

i am interested to know what you would do another way.

yes the resulting card works on a real Mega65-fpga-version.
note that after running the script, i then copy on all the files so that they are not fragmented.
i dont think the m65-dos can handle fragments or long-filenames.
also if you delete a file, it seems to cause the m65-dos to look through the entire partition looking for the end or something.
so I regularly run the script, and copy on all files.

i have been able to update a file regularly (every 10 mins) during development, not sure if this just replaces the data or deletes and writes into a new location.

please ensure that you use a KICKUP file with at least version 00.06.

and do you use the usb-serial-debugger during bootup?
because i found that really useful in seeing what was happening with the m65-dos.

how does your emulator do switches? because the fpga board has SW-12 to be on to get the debug messages.

LGB Gábor Lénárt

unread,
Sep 5, 2016, 11:34:52 AM9/5/16
to C65GS Development
Hi,


On Monday, September 5, 2016 at 2:54:52 PM UTC+2, Ben-401 wrote:
i am interested to know what you would do another way.

Oh, please do not treat that as an offensive statement or anything like that! Far from it. What I remember now, maybe this one is enough (I see your point on using wc -l for number of lines etc then checking the number of matched lines, etc, but that is a bit too complex solution for my taste):

if mount | grep -q "^$1" ; then

But of course, the functionality is about the same, so truly, it's not so much an important thing, sorry for even mentioning it.


About the image:

There is something interesting here with the filesystem it seems. Deft sent me an SD card image (thanks!), and that worked (with my emulator I mean, without any problem). Since you told, it's OK for you with your own created one as well, there must be with the copying files process maybe (at my side, I mean, FS creation should be OK, if it worked for you since it should be the very same result). Yes, I am aware of fragmentation, with a new image, I just copy files, and no other modification is done, so hopefully it shouldn't be fragmented at all. How exactly you copied the files? I simply mounted the partition on Linux, and copied the files (maybe I should use some mount options regarding to the FS, or better use mcopy from the mtools package), with the desired name, also caring about the uppercase stuff (though I am not sure if FAT is case sensitive, and I don't mean the OS now, but the disk FS directory entry level, especially with LFNs etc ...). But anyway, even with my image, my emulator booted in the C65 mode, and the C65 ROM itself is loaded by the kickstart, so it can't be totally wrong! The odd thing, that as far as I can tell, it works if a *given* file name is searched for, eg for example C65.ROM. But the disk chooser seems to "scan" the directory and that is the problem that it can't see the end of directory ... Also fragmentation should not apply here anyway, as the files can be loaded by kickstart (ie the C65 ROM) the problem can be seen only at read dir trap issued by the disk chooser utility (SYS49152). I haven't even deleted files, just copied news. With a "brand new" FS created first. I tried several kickup files built myself from all branches of the mega65-core github repository.

Yes, I emulate "hypervisor check points" to be shown, and FPGA-12 switch is emulated to be ON. Btw you can see how it works: http://c65gs.blogspot.hu/2016/09/mega65-emulator-can-run-kickstart-and.html

What I get (the "Hypervisor serial output:" part is printed by my emulator, the checkpoint itself is generated by the kickstart though):

Hypervisor serial output: "Checkpoint @ $8408 A:$14, X:$14, Y:$0F, Z:$00, P:$35 :trap_dos_readdir                        ".
Hypervisor serial output: "Checkpoint @ $8983 A:$10, X:$10, Y:$0F, Z:$00, P:$35 :dos_readdir <entry>                     ".
Hypervisor serial output: "Checkpoint @ $89F7 A:$3F, X:$1B, Y:$0B, Z:$00, P:$35 :next piece (8.3) =???????????           ".
Hypervisor serial output: "Checkpoint @ $8B31 A:$00, X:$1B, Y:$0B, Z:$00, P:$B4 :drce_shortname                          ".
Hypervisor serial output: "Checkpoint @ $8D00 A:$00, X:$1B, Y:$00, Z:$00, P:$37 :drd_deleted_or_invalid_entry            ".

Not counting the first line, the rests repeating. Before this point, I see that valid files are shown, D81's even shown by the chooser. I started to put extra checkpoints in the source, since I can't tell I clearly understand the source at the first glance, maybe it will help me :)

Please note, that I don't think it's the fault of your script, though quite interesting problem for me, at least for some unknown reason to me yet ...
Reply all
Reply to author
Forward
0 new messages