Shop OBEX P1 Docs P2 Docs Learn Events
P2 with Legacy SD Cards - Page 2 — Parallax Forums

P2 with Legacy SD Cards

2

Comments

  • Cluso99Cluso99 Posts: 18,066
    Unfortunately exFAT is patented by Microsoft. While it appears to me that the patent is based on old technology used in the 80's, which I also utilised BTW, it would take someone to challenge the patent.
    The SD group (I think MS is in the group - conflict of interest????) have agreed to use exFAT for newer SD (which includes microSD) cards and pay MS for the privilege, which means anyone supporting these also needs to pay MS too.
    So, the SD Boot ROM cannot support exFAT without Parallax paying MS for every P2, so it doesn't.
    The SD Boot supports FAT32. You can reformat the exFAT cards with FAT32, or you can place P2 boot code on exFAT cards using the MBR (sector 0) methods.
    The SD Boot code currently supports the older cards that use the 9-bit shift. This has nothing to do with whether the card is FAT32 (or FAT16 or FAT=FAT12).

    The time may have come to remove support for the older SD cards ie remove the 9-bit shift option, and remove FAT16 support if it's still there (I cannot recall until I examine the code).

    FWIW the older 1+GB microSD cards are likely SD V2 cards that use the newer 9-bit shift method that SDHC and SDXC use anyway. The old V1 cards use the sector which included the byte address too (9-bit is the byte offset for the 512 bytes per sector).
  • marsman2020marsman2020 Posts: 71
    edited 2019-01-06 04:40
    Please don't confuse the words "want" "like" "think" etc with "best".

    I'm sorry I said anything at all. Heaven forbid that someone who isn't one of the chosen few have an opinion about something.

    Mac and Linux users are in the minority. Someday I'm assuming Parallax would like to sell a lot of P2s to average educational users who are running Windows. I guess eventually Parallax will have to provide a Windows tool to prepare SD cards in a manner that meets the requirements of the boot ROM, or hope that someone in the community is willing to do it for them.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-01-06 05:07
    Please don't confuse the words "want" "like" "think" etc with "best".

    I'm sorry I said anything at all. Heaven forbid that someone who isn't one of the chosen few have an opinion about something.

    Mac and Linux users are in the minority. Someday I'm assuming Parallax would like to sell a lot of P2s to average educational users who are running Windows. I guess eventually Parallax will have to provide a Windows tool to prepare SD cards in a manner that meets the requirements of the boot ROM, or hope that someone in the community is willing to do it for them.

    Since this is a public forum we should feel free to voice our opinions, within reason of course. To disagree with somebody else is par for the course because we are different people, from different backgrounds, with different experiences, with different needs. We all agree though that we really like the P2.

    So don't be offended if I didn't want to be included in the we part of "we'd want to have the widest SD support possible", because I disagree for many reasons and also due to my 15+ years of experience with SD cards at the embedded level. The much more important aspect of SD cards is not in supporting old tech now, but in supporting "old tech" in the future. That is, the current tech which will be old tech in 10 years time. How many 16GB cards will be around then? Certainly a lot more than 2GB or 1GB or less which would be very comical if we tried to use them. Remember the once ubiquitous floppy? I can't even fit one photo onto a disk. Totally useless.

    As to formatting these beasts, my solution is to let the P2 do it, which is why I will develop a comprehensive "disk tool" to format, explore, edit, and report internal information and speed etc. I've done this before so it seems timely to do it again now. Anyway, digital cameras have been formatting their own cards since year dot.


  • Cluso99 wrote: »
    FWIW the older 1+GB microSD cards are likely SD V2 cards that use the newer 9-bit shift method that SDHC and SDXC use anyway. The old V1 cards use the sector which included the byte address too (9-bit is the byte offset for the 512 bytes per sector).

    Hm, did not know that. Is there any way to tell which type you've got? I have a bunch of 2GB cards that I use for old stuff that may choke on SDHC and I wonder which type those are.
  • kwinnkwinn Posts: 8,697
    Please don't confuse the words "want" "like" "think" etc with "best". Specifically we are talking about support for SD boot in the BOOT ROM which does not preclude anyone connecting a floppy drive or a punch tape reader that happens to be lying around. So "widest" support is also not the best either. Old cards "may" still (just) work but their performance can be abysmal compared to any new cheap card you can pick up from the bargain bin. The P2 chip itself is not just any chip we happen to have lying around. We are not supporting serial EEPROM boot either yet I have reels of brand new ones I "could" use.

    As for formatting larger SD cards I believe we can do that easily enough with the P2 itself rather than depending upon MS to do it for us, and besides I'm a Linux man myself and there are Mac people here too, so we don't have that MS problem. I will write an SD formatter for TAQOZ that may be pasted in through the terminal to format a card. Alternatively it can also be backed up onto the serial Flash.

    I think if we could walk into a store and buy 2GB cards then perhaps we should consider support for these, but it has been many many years since that was even possible and now I find that the smallest card I can find in a store is 16GB.

    +1 - No point in supporting old sd cards that are no longer available and may not work. That's only asking for problems.
    I have yet to find a 4GB or higher card that does not work, while about half of the 2GB and under cards I had in my drawers will not work even after trying to reformat them.
  • I agree with dropping support too.

    A P2 formatting tool makes great sense. Peter, any chance it can go into ROM?

  • pik33pik33 Posts: 2,347
    edited 2019-01-06 07:32
    There is no real problem with bigger SDs. Use one of free partitioning/formating tools and format it with fat32 instead of exfat. Windows refuses to format fat32 on anything bigger than 32 GB but if it is already formatted, Windows can see it.
  • Cluso99Cluso99 Posts: 18,066
    pik33 wrote: »
    There is no real problem with bigger SDs. Use one of free partitioning/formating tools and format it with fat32 instead of exfat. Windows refuses to format fat32 on anything bigger than 32 GB but if it is already formatted, Windows can see it.

    Yes. While Windows itself may refuse to format some SD cards, there are other Windows compatible programs that will format such cards fine.
  • Cluso99Cluso99 Posts: 18,066
    Wuerfel_21 wrote: »
    Cluso99 wrote: »
    FWIW the older 1+GB microSD cards are likely SD V2 cards that use the newer 9-bit shift method that SDHC and SDXC use anyway. The old V1 cards use the sector which included the byte address too (9-bit is the byte offset for the 512 bytes per sector).

    Hm, did not know that. Is there any way to tell which type you've got? I have a bunch of 2GB cards that I use for old stuff that may choke on SDHC and I wonder which type those are.

    Yes. I have written both P1 and P2 test programs that identify SD V1, SD V2, and SDHC (identifies as V3 in my programs). The P2 program runs on the FPGA and I am not certain if it runs on the latest P2 codeset. I don't have time to search the forum (or my code) just at the moment.
  • Cluso99 wrote: »
    pik33 wrote: »
    There is no real problem with bigger SDs. Use one of free partitioning/formating tools and format it with fat32 instead of exfat. Windows refuses to format fat32 on anything bigger than 32 GB but if it is already formatted, Windows can see it.

    Yes. While Windows itself may refuse to format some SD cards, there are other Windows compatible programs that will format such cards fine.

    One of the things I always find with Windows is that there are a lot of compatible programs you can use. The sad thing is that many are of dubious quality or intentions, meaning that I don't trust them. Once you do find genuine free/open software, it is a good thing. Can we perhaps have a thread with trusted recommendations and links perhaps? For instance, I will always recommend TeraTerm as the best OSS Windows terminal emulator. There are proper SD Formatters put out by Panasonic (one of the SD card association's founders along with Toshiba and SanDisk), but they might only use exFat for larger cards.
  • I have two SD cards that I tested. An 8GB and a 4 GB. Both are no name brand. The 4GB boots without issue by renaming the OBJ file to _BOOT_P2.BIX, The 8GB does not boot. Both are formatted FAT32.

    If you would like me to do further testing to help ensure proper operation, let me know.

    Thanks,
    Terry
  • ke4pjw wrote: »
    I have two SD cards that I tested. An 8GB and a 4 GB. Both are no name brand. The 4GB boots without issue by renaming the OBJ file to _BOOT_P2.BIX, The 8GB does not boot. Both are formatted FAT32.

    If you would like me to do further testing to help ensure proper operation, let me know.

    Thanks,
    Terry

    I may post some V1.0 TAQOZ code that you can paste in to give you more information about the card. One of the problems I noticed which I need to double check is that if the card was formatted without the usual SD type partitions, that it wouldn't boot _BOOT_P2.BIX although I could see it on the card with TAQOZ.
  • Cluso99Cluso99 Posts: 18,066
    This afternoon I was working on putting back the debug info into the SD Boot code, but I didn't finish it.
    I noticed that the pull-up test for P60 didn't work correctly. Need to check the P2ES hardware. I was running at 25MHz.
  • Cluso99 wrote: »
    This afternoon I was working on putting back the debug info into the SD Boot code, but I didn't finish it.
    I noticed that the pull-up test for P60 didn't work correctly. Need to check the P2ES hardware. I was running at 25MHz.

    I wonder if that pin would need driving low before testing state, to discharge that 47pF I/O cap which is on for the -ES chips.
  • Cluso99Cluso99 Posts: 18,066
    VonSzarvas wrote: »
    Cluso99 wrote: »
    This afternoon I was working on putting back the debug info into the SD Boot code, but I didn't finish it.
    I noticed that the pull-up test for P60 didn't work correctly. Need to check the P2ES hardware. I was running at 25MHz.

    I wonder if that pin would need driving low before testing state, to discharge that 47pF I/O cap which is on for the -ES chips.

    I am driving the pin low first, but it may not be long enough. It's a copy of Chips ROM routine. Didn't have time to try anything.
  • Where can we get the boot test file?
  • ke4pjwke4pjw Posts: 1,065
    edited 2019-01-07 04:04
    Peter,
    I performed some investigation on the SD cad that does not boot. It appears to have just a single partition that is visible to windows.

    SDCardPartition.png

    Additionally I performed the test that Cluso was asking people to try on their SD cards with back in November of 2017. See the attached results.

    I suspect this card needs to be properly formatted. It came with a camera I purchased for my kiddos on Amazon.

    Regards,
    Terry
  • If you plug it into the p2 and fire up TAQOZ you can dump the boot sector number of ways but try.
    0 fopen 0 $200 sd dump

    Just post the result.
  • I forgot, you might need to do a !SD just to make sure it Inits the SD card first.
    TAQOZ# !SD 0 FOPEN 0 $200 SD DUMP 
    00000: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00010: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00020: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00030: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00040: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00050: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00060: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00070: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00080: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00090: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000A0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000B0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000C0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000D0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000E0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    000F0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00100: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00110: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00120: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00130: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00140: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00150: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00160: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00170: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00180: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00190: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    001A0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    001B0: 00 00 00 00  00 00 00 00  B8 B6 06 5D  00 00 00 82     '...........]....'
    001C0: 03 00 0B 50  CA C6 00 20  00 00 00 C0  EC 00 00 00     '...P... ........'
    001D0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    001E0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    001F0: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 55 AA     '..............U.' ok
    
  • Peter,
    Attached are the results from Taqoz with the SD card that will not boot. I hope this information is helpful. Just seems odd that a newer, generic card wouldn't boot.

    If you would like, I can reinitialize the SD card with the SDCardFormatter utility from the SD Card Association and try again.

    Regards,
    Terry
  • garryjgarryj Posts: 337
    edited 2019-01-07 19:25
    ke4pjw wrote: »
    Peter,
    Attached are the results from Taqoz with the SD card that will not boot. I hope this information is helpful. Just seems odd that a newer, generic card wouldn't boot.

    If you would like, I can reinitialize the SD card with the SDCardFormatter utility from the SD Card Association and try again.

    Regards,
    Terry

    Even though Windows is reporting the partition as FAT32, the MBR partition table partition type is $06, which is FAT16. What utility was used to format the card?

    The Windows "recommended partition size for compatability" for FAT16 is 32MB to 2GB. If you re-format using the Windows normal right-click "Format..." and select the "FAT32 (Default)" option, methinks it will then boot just fine.

    Edit: Ah, I see the card came with a camera. If it hasn't been reformatted since, my guess was they may have used a custom formatting tailored for their product.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-01-08 00:59
    Yes, I am building up disk tools but the partition entry is a pita due to its legacy CHS (cylinder/head/sector) or LBA convention. The SD card itself is accessed as sectors of 512 bytes but as clusters of sectors in FAT etc. I am building up the card information utilities that also report back card speeds and actual speeds and latencies as well as a used sector map.

    Even the MOUNT word reports back a lot just in one line, both about the card's origin and id, and FAT32 info.
    TAQOZ# MOUNT 
    CARD: SANDISK   SD SL08G REV$80 #0168665696 MADE:2016/9 - FAT32: $63FE_C331 P2D2       32k 7,576M ok
    

    KE4pjw Partition: (listed manually)
    80          ACTIVE
    47          PARTITION START HEAD
    04 01       PARTITION START CYLINDER/SECTOR
    06          FAT16
    20          END HEAD
    E0 90       END CYLINDER/SECTOR 
    000030FC    SECTOR OFFSET
    00EE0F04    TOTAL SECTORS IN THIS PARTITION     
    
  • Reformatting the SD card with Windows defaults solved the boot issue. I wish I understood why Windows was mounting it as FAT32, when the MBR clearly showed it as FAT16. When I performed a diskpart, it clearly thought the volume in the partition was FAT32.

    So these are the kinds of things we can expect to see in the forums. Step one, reformat FAT32 :) I wasn't so much worried that we couldn't get it to boot, as I was about knowing what the issue was. Thanks for everyone posting and I hope this helps someone else in the future.
  • That's why having the P2 format a card for you from ROM is a really neat feature to have. So as long as it is SDHC or SDXC it will format it correctly not only to FAT32 specs but also to proper SD formatting specs with the free area before the FAT32 partition. It would be easy enough to make it a partitioning tool as well, especially so if it does not have any files you want to save (new card).
  • ke4pjw wrote: »
    Reformatting the SD card with Windows defaults solved the boot issue. I wish I understood why Windows was mounting it as FAT32, when the MBR clearly showed it as FAT16. When I performed a diskpart, it clearly thought the volume in the partition was FAT32.

    So these are the kinds of things we can expect to see in the forums. Step one, reformat FAT32 :) I wasn't so much worried that we couldn't get it to boot, as I was about knowing what the issue was. Thanks for everyone posting and I hope this helps someone else in the future.
    Glad it all worked out. Windows reporting it as FAT32 may have something to do with this:
    If(CountofClusters < 4085) {
    /* Volume is FAT12 */
    } else if(CountofClusters < 65525) {
    /* Volume is FAT16 */
    } else {
    /* Volume is FAT32 */
    }
    This is the one and only way that FAT type is determined. There is no such thing as a FAT12 volume
    that has more than 4084 clusters. There is no such thing as a FAT16 volume that has less than 4085
    clusters or more than 65,524 clusters. There is no such thing as a FAT32 volume that has less than
    65,525 clusters. If you try to make a FAT volume that violates this rule, Microsoft operating systems
    will not handle them correctly because they will think the volume has a different type of FAT than
    what you think it does.
    
    It was definitely an 8GB partition, because the MBR says there are 15,601,412 sectors. Even if it was a FAT16 using 64KB clusters the largest possible volume would be 4GB. The math just didn't work.
  • why having the P2 format a card for you from ROM

    Right on! Lots of ways people can do it, and they will. Once they get a system, or board they are familiar with, doing it right there will be very compelling.
  • msrobotsmsrobots Posts: 3,701
    edited 2019-01-08 06:40
    That's why having the P2 format a card for you from ROM is a really neat feature to have. So as long as it is SDHC or SDXC it will format it correctly not only to FAT32 specs but also to proper SD formatting specs with the free area before the FAT32 partition. It would be easy enough to make it a partitioning tool as well, especially so if it does not have any files you want to save (new card).

    Yes, @"Peter Jakacki" , please include that.

    And if you can fit it somehow your SPLAT(?) tool.

    forget blink and others if you run out of space.

    Mike
  • ElectrodudeElectrodude Posts: 1,614
    edited 2019-01-08 06:05
    While you're at it with the formatter, could you also add a feature to write boot code into the MBR that, when booted, launches TAQOZ in such a way that it also runs either some TAQOZ bytecode in the MBR or compiles and runs TAQOZ code in a file on the SD card?

    This would allow writing large SD-card-based applications for the P2 with nothing more than a P2 and a computer with a text editor and an SD card reader. It would also allow cramming more custom boot code into the MBR, since TAQOZ bytecode is denser than PASM2.
  • @Electrodude,

    as far as I read somewhere here @"Peter Jakacki" has already included the ability to save the actual system into the SD bootfile(s) for the ROM SD booter from @Cluso99 . And you can set a auto start vector so that after loading from SD your user defined word gets executed.

    Theoretically.

    I was not able yet to do that. (was not able to do that, yet?).

    This does not use the MBR but the FAT32 file system.

    And, as far as I could follow this will be in the next ROM, not the current one.

    Mike
  • Yes, the current ROM has a bug/feature whereby the area at address 0 is overwritten and so the saved image fails to boot. Sure I could patch that but it is easy enough to test the next intermediate version using one of the current boot images. You can use this, add your stuff, and run MAKEBOOT to update the BIX file.

    As soon as I can I will release another image with some disk utilities in it which I will expand upon to develop this into the disk tool and formatter.
Sign In or Register to comment.