[Oberon] Project Oberon - Copying files to the SD card

Jörg Straube joerg.straube at iaeth.ch
Sat Jan 10 00:29:11 CET 2015


I have a prototype of this running under ETHOberon on Windows.
Some hints:
- My Oberon code finds the physical drive nbr itself by enumerating all drives and checking capabilities.
- Being able to have lowlevel access to the SD card, I had to prevent Windows to access the SD card by unmounting the drive first.
- As Chris wrote ETHOberon must be "run as admin".
br, Jörg

Am 09.01.2015 um 23:52 schrieb Chris Burrows <chris at cfbsoftware.com>:

>> 
>> From: Bill Buzzell [mailto:captbill279 at gmail.com]
>> Sent: Thursday, 8 January 2015 4:51 AM
>> To: oberon at lists.inf.ethz.ch
>> Subject: Re: [Oberon] Oberon Digest, Vol 128, Issue 6
>> 
>> How do you move files onto the SD card? Anyone know? I tried
>> extracting the ISO and adding files and un-extracting it again. None
>> of the files appear visible to Oberon though. Am I using the wrong
>> encoding somehow?
> 
> If you want files on the SD card to be visible from Project Oberon then you need to create them with the appropriate file headers and directory entries as explained in great detail in Chapter 7 The File System of the Project Oberon documentation. 
> 
> You should write a program to do this on the system you want to transfer files from. As the Project Oberon source code is provided most of the hard work is already done for you. However, before you do this you need to understand: 
> 
> a) how to access the SD Card on your system 
> b) how to perform low-level block IO to / from a storage device on your system
> c) the Project Oberon modules Files, FileDir and the disk IO procedures from Kernel.
> 
> I used BlackBox Component Pascal v1.6 on Windows 7 as much of the Project Oberon source code (Files.mod and FileDir.mod) can be used with minimal changes, SYSTEM.VAL is compatible with Project Oberon and BlackBox has access to the relevent WinApi system calls:
> 
>  http://www.oberon.ch/blackbox.html
> 
> If you plan to transfer files from a Windows 7 system to / from the SD Card the following should help get you started:
> 
> 
> a) how to access the SD Card on your system
> 
> If you cannot access the SD card via SPI on your system you need to find out how to access it as a raw (i.e. not formatted) device. On Windows the device name convention is \\.\<drivenumber>. On my system the drivenumber is "6" because my SD card appears as Drive 6 in:
> 
>  Admin Tools > Computer Management > Storage > Disk Management
> 
> The 8GB Project Oberon SDHC Card appears with a 255MB FAT partition, a 64 MB Primary partition and 7.09GB unallocated
> 
> 
> b) how to perform low-level block IO to / from a storage device on your system
> 
> The corresponding BlackBox procedure to access this drive using WinApi.CreateFileW is:
> 
>  PROCEDURE Open*(driveName: FullName);
>  VAR
>    physicalName: FullName;
>  BEGIN
>    physicalName := "\\.\" + driveName;
>    drive.handle :=  
>      WinApi.CreateFileW(
>        physicalName, 
>        WinApi.GENERIC_READ + WinApi.GENERIC_WRITE, 
>        WinApi.FILE_SHARE_READ + WinApi.FILE_SHARE_WRITE, 
>        NIL, 
>        WinApi.OPEN_EXISTING, 
>        {}, 
>        0)  
>  END Open;
> 
> You also need to implement the equivalent of the low-level sector read / write functions (i.e. Kernel.GetSector and Kernel.PutSector). On Windows the WinApi calls you can use to do this are  
> 
>  WinApi.SetFilePointer
>  WinApi.ReadFile
>  WinApi.WriteFile
>  WinApi.GetLastError
>  WinApi.CloseHandle
> 
> e.g PutSector becomes:
> 
>  PROCEDURE PutSector*(sectorNo: INTEGER; sector: ARRAY OF BYTE);  
>  VAR
>    i, org, count, bytesWritten, res: INTEGER;
>  BEGIN
>    ASSERT(sectorNo MOD 29 = 0); 
>    sectorNo := sectorNo DIV 29; 
>    sectorNo := sectorNo * 2 + FSoffset;
>    org := sectorNo * (SectorSize DIV 2);
>    i := 0;
>    i := WinApi.SetFilePointer(drive.handle, org, i, WinApi.FILE_BEGIN);
>    count := SectorSize;
>    IF (WinApi.WriteFile(drive.handle, SYSTEM.ADR(sector), count, bytesWritten, NIL) = 0) 
>      OR (bytesWritten < SectorSize) THEN
>        res := WinApi.GetLastError(); 
>        HALT(102)
>    END;
>  END PutSector;
> 
> NOTE: Windows requires you to run programs that access raw storage devices in 'Administrator Mode'.
> 
> Regards,
> 
> Chris Burrows
> CFB Software
> Astrobe: Oberon for ARM Microcontrollers
> http://www.astrobe.com
> 
> 
> 
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list