Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


All steps to format / setup a bootable SD card can only be performed within a Linux.

An installation of INTEL SoC FPGA EMBEDDED DEVELOPMENT SUITE, so the tool
alt-boot-disc-util (mk(p)image) is present.

Background


The boot process of the HPS consists of several stages:

  • Boot ROM
     - Hard coded into the chip
     - It's purpose is to detect the selected boot source
     - Perform minimal Setup of the HPS
     - Load the next Boot stage [Preloader / u-boot-spl] into the On chip RAM [OCRAM]
        therefore the preloader / SPL u-boot is limited to 64 kByte on Cyclone 5 devices

  • Preloader
     - Perform additional HPS initialization
     - Bring up SDRAM
     - Load the next boot stage from Flash to SDRAM and jump to it
     - Preloader-optins:
            u-boot - SPL
            SoC EDS - MPL [Altera bare-metal libraries - HWLibs]
     - For Cyclone 5 devices, the preloader consists of 4 identical copies. each 64 kB in size,
        256 kb in total
     - When generating the preloader, it can be necessary to manually add a checksum and
       a mark for recognition into the binary, the tool mk(p)image can perform these additions

  • Main Bootloader
     - Load Linux [u-boot] or Bare Metal Application into the RAM
     - Jump to it.
       In case of Linux, load Kernel, followed by the loading of the Linux rootfs



Partitions within the SD card

...

Unknown - partition for u-boot config script and how to setup (uboot.scr)
vfat-partition:          optional - Linux-Config-Script / main u-boot instead a2-partition

...


To partition the SD card, Linux offers the command line tool fdisk [sfdisk].
        BEWARE!    fdisk  [sfdisk] can operate on every disk within the system and does not ask for approval.

...

RM = Removable ? → sdc is the sd SD card with one partition sdc1

Format the card - Manual approach:

...

Type p to list all existing partitions.
Type d to erase a partition.
Type n to edit a new partition.
Type t to set the partition type (default is Linux / 83).
Type a to mark partition as active.

Output for p:    For convenience, the partition table listed is the one which the SD card needs to be setup to
                         Sizes may vary

...

            Partition type → Select p   ;    Partition number → Enter   ;   First sector → Enter
            Last sector → +size{K,M,G} / example: 20 MB partition →  +20M

Step 3: Set partition type → Type t
            c=(W95 FAT32 (LBA))    a2=Altera boot partition   83=Linux, default value

Step 4: Repeat step 2 and 3 until all partitions are editedcreated

Step 5: Write the new table to th SD card → Type w

...

Copy to a textfile and save the following in between ----- .

------------------------------
unit: sectors

/dev/sdb1 : start= 2048, size= 204800, Id= c
/dev/sdb2 : start= 206848, size= 4096000, Id=83
/dev/sdb3 : start= 4302848, size= 4096, Id=a2
/dev/sdb4 : start= 0, size= 0, Id= 0

unmount

run fsdisk

Data of each partition

------------------------------

To create the partition table run:
   sudo umount /dev/sdX*     (umounts device)
   sudo sfdisk /dev/sdX < PathToTextFile

To read the partition table from a storage device:
   sudo sfdisk -d /dev/sdX > PathToTextFile

Data of each partition

Before writing data to the partitions, umount the device
      sudo umount /dev/sdX*
and plage the SD card  in and out of the card reader.

W95 Fat32 partition

The W95 Fat32 partition needs to be formated.
   ( sudo umount /dev/sdX* )
   sudo mkfs -t vfat /dev/sdX-nummer/sdXp (p=partition number, needs to be 1)

After the operation finishes, use a data browser to copy the
Linux kernel / zImage(.bin)   and the   device tree blob / socfpga.dtb.

ext(2/3/4) partition

The ext(2/3/4) partition is formated via:
   sudo mkfs.ext3 /dev/sdX-nummer

vFat zimage and dtb

/sdXp (p=partition number, should be 2)

After the operation finishes, use a data browser to copy the
Linux root file system / rootfs   to it.

An other approach is needed for a compressed root file system.
Befor decompressing a ... .tar.gz file to the SD card, it needs to be mounted to
a mounting point. This requires an existing folder to write to.

Usually these folder is placed inside the mnt folder, for example:
   sudo mkdir /mnt/card   (create mounting point folder)

Mount it:
   sudo mount /dev/sdXp /mnt/card   (p=partition number, should be 2)

Extract the ... .tar.gz file to the partition:
   sudo tar -xvf pathToCompressed.tar.gz -C /mnt/card/   (x=decompress v=show progress -C=extract to)
   sudo sync   (imported, empty all buffers)

a2 partition

This partition need no formatting, the data needs to be copied with the tool
alt-boot-disk-util .

The tool should be in the folder:
   \intelFPGA\18.1\embedded\host_tools\altera\diskutils
Copy the   SPL u-boot.bin   and   the Main u-boot.img   to it and run:
   a2, nur sd card angeben, keine partition, wird selbsttätig gesucht
sudo ~/intelFPGA/19.1/embedded/host_tools/altera/diskutils/alt-boot-disk-util -p preloader-mkpimage.bin -b u-boot.img -a write /dev/sdb

Mounting point erstellen.
mount /dev/sdb1 /mnt/card
card ist der mounting point, wenn der Ordner nicht besteht,
gibts ne Fehlermeldung -> Lösung, Ordner erstellen
Danach kann man z.b. zu dem mounting point entpacken,
aber, syncen nicht vergessen

Check file system:
sudo fsck /dev/sdxy
Besser:
sudo mkfs.ext(2/3 oder 4) 7dev/sdxy

   sudo pathToAlt-boot-disk-util -p preloaderImage.bin -b mainU-boot.img -a write /dev/sdX   (the tool finds the a2 partition)

Lastly, unmount the Sd card and test it.


(The tool dd can also be used to write the preloader - sudo dd if=pathToSplUboot of=/dev/sdXp seek=0 bs=64k conv=fsync)sudo tar -xvf ~/Desktop/arrow-sockit/arrow-sockit-console-image-minimal-arrow-sockit-20191121221211.rootfs.tar.gz -C /mnt/card/