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

Chris Burrows chris at cfbsoftware.com
Fri Jan 9 23:52:36 CET 2015

> 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:


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);
    physicalName: FullName;
    physicalName := "\\.\" + driveName;
    drive.handle :=  
  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  


e.g PutSector becomes:

  PROCEDURE PutSector*(sectorNo: INTEGER; sector: ARRAY OF BYTE);  
    i, org, count, bytesWritten, res: INTEGER;
    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(); 
  END PutSector;

NOTE: Windows requires you to run programs that access raw storage devices in 'Administrator Mode'.


Chris Burrows
CFB Software
Astrobe: Oberon for ARM Microcontrollers

More information about the Oberon mailing list