UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer philtempblue
Observer
4,246 Views
Registered: ‎02-05-2018

Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

Hello,

 

I'm really new to PeteLinux and have been searching for an answer to this; however, all the posts I find are not exactly at the level I need.

 

I am currently booting PetaLinux from an SD card onto a PicoZed 7020.  I used the instructions in ug1144 and everything is working well. 

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_1/ug1144-petalinux-tools-reference-guide.pdf

 

The SD card has three partitions: the first and second partitions are the BOOT and rootfs partitions, created and populated using ug1144 (pages 48-50).  The file system contents within the rootfs partition are loaded into ramdisk upon boot. The third partition is an ext4 partition that I'm using to store "whatever" files... let's call it the whateverpartition

 

All three partitions appear under /dev as mmcblk0p1 (BOOT partition), mmcblk0p2 (rootfs partition), and mmcblk0p3 (whateverpartition partition) after boot-up.  Of course, the file system contained within the second partition is loaded into ramdisk successfully.  I can use the mount command to mount any of these partitions to manually created sub-directories within /media directory.

 

What I need help with is understanding how to configure PetaLinux (u-boot or whatever?) to do the following on boot:

  1. Auto create an arbitrary mount directory /media/sdpart3
  2. Auto mount the mmcblk0p3 to the /media/sdpart3

I understand that this is usually accomplished by modifying the init.d script.  However, since PetaLinux builds the rootfs, I'm not sure where I need to include any instructions for performing the auto mount.  I'm assuming the best way of doing this does not involve manually modifying the rootfs after building it as a PetaLinux project.

 

Any help is appreciated; bonus points for clear instructions that assume a 5-year old is trying to follow them!

 

Thanks!

1 Solution

Accepted Solutions
5,052 Views
Registered: ‎04-20-2017

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

you are already on the right track. Look at the .pdf you quoted on page 59, how to start an application on bootup.

 there the application is started with a shell script, that is loaded as part of initd . (last on the lowest runlevel)

 

instead of running an application, you can just do whatever in that shellscript (like mounting you sd card,...)

 

I was just frustrated that it does not work as it is described in the manual...you have to add an additional line to the recipe...

 

install -m 0755 ${S}/GetIP-init ${D}${sysconfdir}/rcS.d/S99GetIP-init

where GetIP-init is my shell script that is run on bootup

 

here are my recipes  in the meta-user/apps/myapp layer where i add it

 

please accept as solution

5 Replies
5,053 Views
Registered: ‎04-20-2017

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

you are already on the right track. Look at the .pdf you quoted on page 59, how to start an application on bootup.

 there the application is started with a shell script, that is loaded as part of initd . (last on the lowest runlevel)

 

instead of running an application, you can just do whatever in that shellscript (like mounting you sd card,...)

 

I was just frustrated that it does not work as it is described in the manual...you have to add an additional line to the recipe...

 

install -m 0755 ${S}/GetIP-init ${D}${sysconfdir}/rcS.d/S99GetIP-init

where GetIP-init is my shell script that is run on bootup

 

here are my recipes  in the meta-user/apps/myapp layer where i add it

 

please accept as solution

Observer philtempblue
Observer
4,190 Views
Registered: ‎02-05-2018

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

This was a huge help!  Thanks for the response.  I was able to successfully mount the partitions this way.  For completeness, I'm including the steps and recipes I used to make this happen:

 

  • I followed the steps on page 59-60 (steps 1 and 2 only).
  • Called my application "mount-sd-partitions-init"
  • This created the folder containing the "mount-sd-partitions-init.bb" file.
    • Modified the file to include the highlighted elements on page 59 step 2, and modified the application name appropriately (see first code block below)
  • Then navigated into the "files" sub-folder and edited the "mount-sd-partitions-init" script (see second code block below).
    • ... where "sddata" is the "whatever" partition I spoke of earlier. 
  • Skipped step 3 on page 60, because it doesn't need to be a daemon.
  • Ran >> petalinux-build
  • Followed the normal steps on page 48-50 to install the build products into the BOOT and rootfs partitions.

 

#
# This file is the mount-sd-partitions-init recipe.  file="mount-sd-partitions-init.bb"
#

SUMMARY = "Simple mount-sd-partitions-init application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://mount-sd-partitions-init \
	"

S = "${WORKDIR}"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

inherit update-rc.d

INITSCRIPT_NAME = "mount-sd-partitions-init"
INITSCRIPT_PARAMS = "start 99 S ."

do_install() {
	     install -d ${D}/${sysconfdir}/init.d
	     install -m 0755 ${S}/mount-sd-partitions-init ${D}/${sysconfdir}/init.d/mount-sd-partitions-init
}

FILES_${PN} += "${sysconfdir}/*"
#!/bin/sh

#This is the "mount-sd-partitions-init" script within /files

echo "Mounting SD Card Partitions to /media/: sdrootfs, sdboot, sddata"

mkdir -m 755 /media/sdboot
mount -t vfat /dev/mmcblk0p1 /media/sdboot/

mkdir -m 755 /media/sdrootfs
mount -t ext4 /dev/mmcblk0p2 /media/sdrootfs/

mkdir -m 755 /media/sddata
mount -t ext4 /dev/mmcblk0p3 /media/sddata/


I know my script to mkdirs and mount the partitions is probably very rudimentary; I welcome any suggestions!

 

0 Kudos
Moderator
Moderator
4,125 Views
Registered: ‎04-24-2017

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

Hi juergen.kratochwill@grapho-metronic.com,

 

Rather than creating your own init scripts yocto already provides this option just add an mount entry in fstab.

 

Create a bbapend file as shown below

 

$ vim project-spec/meta-user/recipes-core/base-files/base-files/base-files_%.bbappend

Add fstab

SRC_URI += "file://fstab"
FILESEXTRAPATHS_prepend := "${THISDIR}/base-files:"

fstab content:

# stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
/dev/mmcblk0p1       /media/card          auto       defaults,sync         0  0

Once yocto or petalinux is boot is up and running you can find the mount under /run/media/mmcblk0p1.

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
4,111 Views
Registered: ‎04-20-2017

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

ahh very helpful, esp. when replacing files that are pre-existent in the recipes

0 Kudos
Contributor
Contributor
344 Views
Registered: ‎05-31-2019

Re: Help With Auto Mounting SD Card Partition to /media - PetaLinux

Jump to solution

Hi @philtempblue juergen.kratochwill@grapho-metronic.com ,

 

I am having three partitions in my SD card. The first and second partitions are the BOOT and rootfs partitions, the third partition is an ext4 partition that I'm using to store some files. Now when I am loading this SD card to my ZCU104 board, it shows me the directory structure from the second partition.

I want to know if it is possible to view the third partition inside the FPGA, and if so how? Can I copy the files from the third partition to my directory structure which was populated by the second partition? Thanks.

0 Kudos