Page 1 of 1

Implementing SD in Linux for SAM9x35

Posted: Fri Jun 14, 2019 3:18 pm
by AleFachini
Hello Again forums:
I have to implement saving a txt file to SD card connected to a SAM9x35 HSMCI0 port.
I can't recompile linux so here it is the log of it to check version and something you may need to help me.

Code: Select all

RomBOOT


AT91Bootstrap 3.5.4 (Tue Dec 13 15:37:08 ART 2016)

1-Wire: Loading 1-Wire information ...
1-Wire: ROM Searching ... Done, 0x1 1-Wire chips found

1-Wire: BoardName | [Revid] | VendorName
  #0x0  SOM9X35 [B1]      APEXAR
1-Wire: Failed to read DM board information
1-Wire: Failed to read EK board information

1-Wire: SYS_GPBR2: 0xc6, SYS_GPBR3: 0x8001

NAND: ONFI flash detected
NAND: Manufacturer ID: 0x2c Chip ID: 0x32
NAND: Disable On-Die ECC
NAND: Initialize PMECC params, cap: 0x2, sector: 0x200
NAND: Image: Copy 0x280000 bytes from 0x200000 to 0x22000000

Image magic: 0x27051956 is found
Relocating kernel image, dest: 0x20008000, src: 0x22000040
 ...... 0x26e364 bytes data transferred
Not calendar
Last Reset: Wake Up
Power Button: 0x1
Backlight: 0x1

Starting linux kernel ..., machid: 0xd2d

Uncompressing Linux... done, booting the kernel.
Linux version 2.6.39_som9x35-1.1.1 (lucas@ziggy.apexar) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #3 Fri Dec 23 11:04:31 ART 2016
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: Atmel AT91SAM9X5-EK
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 400 MHz, master 133 MHz, main 12.000 MHz
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: mem=128M console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/kernel)ro,-(rootfs) rw rootfstype=jffs2 root=/dev/mtdblock1 rootwait poweron=normal
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 124200k/124200k available, 6872k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xff000000 - 0xffe00000   (  14 MB)
    vmalloc : 0xc8800000 - 0xfee00000   ( 870 MB)
    lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0047000   ( 252 kB)
      .text : 0xc0047000 - 0xc0537700   (5058 kB)
      .data : 0xc0538000 - 0xc0579520   ( 262 kB)
NR_IRQS:192
AT91: 128 gpio irqs in 4 banks
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 199.06 BogoMIPS (lpj=995328)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
I2C BITBANGING - ID:0
AT91: CM rev B and higher
AT91: Power Management (with slow clock mode)
AT91: Starting after power-restored wakeup
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c-gpio i2c-gpio.0: using pins 96 (SDA) and 97 (SCL)
at_hdmac at_hdmac.0: Atmel AHB DMA Controller ( cpy slave ), 8 channels
at_hdmac at_hdmac.1: Atmel AHB DMA Controller ( cpy slave ), 8 channels
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
Switching to clocksource tcb_clksrc
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
msgmni has been set to 242
io scheduler noop registered (default)
atmel_hlcdfb atmel_hlcdfb_base.0: 1500KiB frame buffer at 27a00000 (mapped at ffc00000)
Console: switching to colour frame buffer device 60x34
atmel_hlcdfb atmel_hlcdfb_base.0: fb0: Atmel LCDC at 0xf8038000 (mapped at c8864000), irq 25
atmel_hlcdfb atmel_hlcdfb_ovl.0: 1500KiB frame buffer at 27000000 (mapped at ffa00000)
atmel_hlcdfb atmel_hlcdfb_ovl.0: fb1: Atmel LCDC at 0xf8038100 (mapped at c886c100), irq -6
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xf8040000 (irq = 15) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xf8044000 (irq = 16) is a ATMEL_SERIAL
brd: module loaded
loop: module loaded
ssc ssc.0: Atmel SSC device at 0xc8888000 (irq 28)
i2c-core: driver [tsl2550] using legacy suspend method
i2c-core: driver [tsl2550] using legacy resume method
atmel_nand atmel_nand: Using dma0chan0 for DMA transfers.
ONFI flash detected
ONFI param page 0 valid
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xaa (Micron MT29F2G08ABBEAHC)
atmel_nand atmel_nand: Initialize PMECC params, cap: 2, sector: 512
Scanning device for bad blocks
2 cmdlinepart partitions found on MTD device atmel_nand
Creating 2 MTD partitions on "atmel_nand":
0x000000000000-0x000000800000 : "bootstrap/kernel"
0x000000800000-0x000010000000 : "rootfs"
atmel_spi atmel_spi.1: Using dma1chan0 (tx) and  dma1chan1 (rx) for DMA transfers
atmel_spi atmel_spi.1: Atmel SPI Controller at 0xf0004000 (irq 14)
CAN device driver interface
PPP generic driver version 2.4.2
macb macb.0: invalid hw address, using random
macb macb.0: eth0: Features changed: 0x00004800 -> 0x00004000
MACB_mii_bus: probed
eth0: Atmel MACB at 0xf802c000 irq 24 (7e:da:23:13:db:cf)
eth0: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=0:01, irq=-1)
usbcore: registered new interface driver zd1211rw
usbcore: registered new interface driver rt2500usb
usbcore: registered new interface driver rt73usb
usbcore: registered new interface driver rt2800usb
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
atmel-ehci atmel-ehci: Atmel EHCI UHP HS
atmel-ehci atmel-ehci: new USB bus registered, assigned bus number 1
atmel-ehci atmel-ehci: irq 22, io mem 0x00700000
atmel-ehci atmel-ehci: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 3 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 2
at91_ohci at91_ohci: irq 22, io mem 0x00600000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 3 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver libusual
atmel_usba_udc atmel_usba_udc: MMIO registers at 0xf803c000 mapped at c8892000
atmel_usba_udc atmel_usba_udc: FIFO at 0x00500000 mapped at c8900000
atmel_tsadcc atmel_tsadcc: Master clock is set at: 133333333 Hz
atmel_tsadcc atmel_tsadcc: Prescaler is set at: 221
input: atmel touch screen controller as /devices/platform/atmel_tsadcc/input/input0
at91_rtc at91_rtc: rtc core: registered at91_rtc as rtc0
AT91 Real Time Clock driver.
i2c /dev entries driver
Linux media interface: v0.10
Linux video capture interface: v2.00
gspca: v2.12.0 registered
usbcore: registered new interface driver uvcvideo
USB Video Class driver (v1.0.0)
Driver for 1-wire Dallas network protocol.
w1_master_driver w1 bus master: Family 2d for 2d.000009e415de.67 is not registered.
AT91SAM9 Watchdog: sorry, watchdog is disabled
at91_wdt: probe of at91_wdt failed with error -5
Software Watchdog Timer: 0.07 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout= 0)
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
asoc: wm8731-hifi <-> atmel-ssc-dai.0 mapping ok
ASoC: at91sam9x5ek_init ok
ALSA device list:
  #0: AT91SAM9X5
TCP cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20090105 abi 8)
NET: Registered protocol family 29
can: raw protocol (rev 20090105)
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
at91_rtc at91_rtc: setting system clock to 2007-01-01 00:00:07 UTC (1167609607)
atmel_mci atmel_mci.0: Using dma0chan1 for DMA transfers
atmel_mci atmel_mci.0: Atmel MCI controller at 0xf0008000 irq 12, 1 slots
Empty flash at 0x03b7690c ends at 0x03b77000
VFS: Mounted root (jffs2 filesystem) on device 31:1.
Freeing init memory: 252K
udevd (588): /proc/588/oom_adj is deprecated, please use /proc/588/oom_score_adj instead.
SoftDog: Unexpected close, not stopping watchdog!
Initializing random number generator... done.
Starting network...
ip: RTNETLINK answers: File exists
Starting sshd: OK
 calibrated
Simple mixer control 'Master',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 127
  Mono:
  Front Left: Playback 127 [100%] [6.00dB]
  Front Right: Playback 127 [100%] [6.00dB]
Simple mixer control 'Output Mixer HiFi',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
SoftDog: Unexpected close, not stopping watchdog!
Playing WAVE '/opt/SOUNDS/conciencia.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
MemTotal:         124452 kB
MemFree:          108840 kB
Buffers:               0 kB
Cached:             7420 kB
SwapCached:            0 kB
Active:             2348 kB
Inactive:           5728 kB
Active(anon):        656 kB
Inactive(anon):        4 kB
Active(file):       1692 kB
Inactive(file):     5724 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:           672 kB
Mapped:             1492 kB
Shmem:                 4 kB
Slab:               3164 kB
SReclaimable:        852 kB
SUnreclaim:         2312 kB
KernelStack:         256 kB
PageTables:           96 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       62224 kB
Committed_AS:       2048 kB
VmallocTotal:     890880 kB
VmallocUsed:      266504 kB
VmallocChunk:     620540 kB

I would like to know if i have the drivers for the SD installed and how should i approach this, i don't have idea how to do it i've never done it.

I can explore the files that will be compiled in the RFS over the kernel but the kernel per se is a pre-compiled binary i can't modify.

Also any link you can suggest me for me to get started would be awesome too.

Thank you very much.


EDIT:

So trying to get something i found that if i do:

1º) Put SD IN SLOT
2º) Type:
df | grep -q partition (enter)
3º) Remove SD and Reinsert SD. I get this msg:
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address 0001
mmcblk0: mmc0:0001 SD32G 28.9 GiB
mmcblk0: detected capacity change from 0 to 31104958464
mmcblk0: unknown partition table
4º) doing now:
ls /dev
I obtain mmcblk0 listed that previously was not there
5º) Still Mount command on a /mnt/sd-fs i created throws:
can't find /mnt/sd-fs in /etc/fstab
6º) if i retire the SD and reinsert this wont happen until i start step 1 again.
When Removed SD console says mmc0 removed


Please Helpp me with anything you can. i need to mount only for saving files.
This kernel has Busybox if it helps.
I dont have fdisk installed.

Re: Implementing SD in Linux for SAM9x35

Posted: Fri Jun 14, 2019 11:43 pm
by blue_z
The boot log does indicate that the atmel_mci driver is built into the kernel.
FYI There could be other drivers built for this kernel stored in the /lib/modules directory of the root filesystem.

Inserting a (formatted) SD card (and mounting the filesystem) would be one test of available functionality.

Your stated goal of "saving a txt file to SD card" is ambiguous.
You only specify the physical medium, which happens to be a block device.
Unless you intend to access the SD card as raw sectors, then that block device is expected to have a MBR partition table and have a filesystem installed.
The filesystem you use on the SD card also has to be supported by your board's kernel.

The filesystems supported by your board's kernel can be listed with the shell command:

Code: Select all

# cat /proc/filesystems

Apparently the SD card you are testing with has been wiped, and has no partition table and therefore no filesystems.
You need to decide if you are going to use the raw device, or install a partition table and choose a filesystem (vfat, ext2/3/4) for that SD card.

Regards

Re: Implementing SD in Linux for SAM9x35

Posted: Wed Jun 19, 2019 4:17 pm
by AleFachini
Hello and Thank you.

I ve spent whole day trying stuff and I am posting what I've done:

1) from console i did:

Code: Select all

# lsmod
Module                  Size  Used by    Not tainted
Then i went to the RFS files and my /lib has no direct /modules but /lib/gio/modules and its also empty.

The tools at my disposal are listed in my busybox which is as follows:
# busybox
BusyBox v1.16.1 (2011-05-12 11:03:47 ART) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
or: function [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.

Currently defined functions:
[, [[, addgroup, adduser, ar, arping, ash, awk, basename, bunzip2,
bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt,
cksum, clear, cmp, cp, cpio, cut, date, dc, dd, deallocvt, delgroup,
deluser, devmem, df, diff, dirname, dmesg, dnsd, dnsdomainname,
dos2unix, du, dumpkmap, echo, egrep, eject, env, ether-wake, expr,
false, fdflush, fdformat, fgrep, find, fold, free, freeramdisk, fsck,
fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head, hexdump,
hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init,
insmod, install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule,
iptunnel, kill, killall, killall5, klogd, last, length, less, linux32,
linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname,
losetup, ls, lsattr, lsmod, lspci, lsusb, lzmacat, makedevs, md5sum,
mdev, mesg, mkdir, mkfifo, mknod, mkswap, mktemp, modprobe, more,
mount, mountpoint, mt, mv, nameif, netstat, nice, nohup, nslookup, od,
openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,
poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile,
realpath, reboot, renice, reset, resize, rm, rmdir, rmmod, route,
run-parts, runlevel, sed, seq, setarch, setconsole, setkeycodes,
setlogcons, setsid, sh, sha1sum, sha256sum, sha512sum, sleep, sort,
start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, test, tftp,
time, top, touch, tr, traceroute, true, tty, udhcpc, umount, uname,
uniq, unix2dos, unlzma, unzip, uptime, usleep, uudecode, uuencode,
vconfig, vi, vlock, watch, watchdog, wc, wget, which, who, whoami,
xargs, yes, zcat
As you can see no fdisk here.

I got a new sd this time 16gb and formated with gparted as msdos partition and also ext2 format (if these terms are correct). beacause these are the result of cat /proc/filesystems in my embedded:

Code: Select all

 cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   tmpfs
nodev   debugfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   rpc_pipefs
nodev   devpts
        ext2
nodev   ramfs
        vfat
        msdos
nodev   nfs
nodev   nfs4
nodev   jffs2
nodev   mqueue
nodev   mtd_inodefs
nodev   ubifs
Extra Info, i ran cat /proc/devices with my sd detected as follows
# df | grep -q partition
# mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address 0007
mmcblk0: mmc0:0007 SD16G 14.5 GiB
mmcblk0: detected capacity change from 0 to 15590227968
mmcblk0: unknown partition table

# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
13 input
14 sound
29 fb
81 video4linux
89 i2c
90 mtd
108 ppp
116 alsa
128 ptm
136 pts
153 spi
180 usb
189 usb_device
253 media
254 rtc

Block devices:
1 ramdisk
259 blkext
7 loop
8 sd
31 mtdblock
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
179 mmc

# ls /dev
audio ram3 tty44
console random tty45
cpu_dma_latency rtc0 tty46
dsp shm tty47
fb0 snd tty48
fb1 spidev1.0 tty49
full tty tty5
i2c-0 tty0 tty50
input tty1 tty51
kmem tty10 tty52
kmsg tty11 tty53
log tty12 tty54
loop0 tty13 tty55
loop1 tty14 tty56
loop2 tty15 tty57
loop3 tty16 tty58
loop4 tty17 tty59
loop5 tty18 tty6
loop6 tty19 tty60
loop7 tty2 tty61
mem tty20 tty62
mixer tty21 tty63
mmcblk0 tty22 tty7
mtd0 tty23 tty8
mtd0ro tty24 tty9
mtd1 tty25 ttyS0
mtd1ro tty26 ttyS1
mtdblock0 tty27 ttyS2
mtdblock1 tty28 ttyp0
network_latency tty29 ttyp1
network_throughput tty3 ttyp2
null tty30 ttyp3
ppp tty31 ttyp4
ptmx tty32 ttyp5
pts tty33 ttyp6
ptyp0 tty34 ttyp7
ptyp1 tty35 ubi_ctrl
ptyp2 tty36 urandom
ptyp3 tty37 vcs
ptyp4 tty38 vcs1
ptyp5 tty39 vcs3
ptyp6 tty4 vcsa
ptyp7 tty40 vcsa1
ram0 tty41 vcsa3
ram1 tty42 watchdog
ram2 tty43 zero
It keeps saying "unknown partition table" but this time the SD is formated and partitioned with gparted.

I was thinking of adding fdisk to the build but is has to be as module because i can't edit kernel but the RFS which i have access. Is this even possible? I really don't know.

Please correct any error and any advice will be great. Thankyou.

Re: Implementing SD in Linux for SAM9x35

Posted: Thu Jun 20, 2019 1:44 am
by blue_z
AleFachini wrote: It keeps saying "unknown partition table"
What is this "it"?
What happens that causes this message?
How often is "keeps saying"?

AleFachini wrote: but this time the SD is formated and partitioned with gparted.
Do you know how to use GParted?
Did you verify that the SD card is actually partitioned and properly formated with a filesystem?
(Seems like whatever you claimed to do with GParted was not successful.)

AleFachini wrote: I was thinking of adding fdisk to the build but is has to be as module because i can't edit kernel but the RFS which i have access. Is this even possible?
Do you know what fdisk is?
What makes you think you need it?
Fdisk is not part of the kernel; it's a userspace program.

AleFachini wrote: Please correct any error and any advice will be great.
Stop referring to "SD".
There is no device called "SD" or Secure Digital.

Regards

Re: Implementing SD in Linux for SAM9x35

Posted: Fri Jun 21, 2019 4:13 pm
by AleFachini
blue_z wrote: What is this "it"?
What happens that causes this message?
How often is "keeps saying"?
The console of the kernel. I mean is what i read in the console's output connected from my pc to the SOM. Each time i connect the MMC into the slot i get the same message, listed in my previous post "mmc0: unkown partition table."
blue_z wrote: Do you know how to use GParted?
Did you verify that the MMC card is actually partitioned and properly formated with a filesystem?
(Seems like whatever you claimed to do with GParted was not successful.)
Nope, I mean I DO KNOW HOW TO USE IT (i think im not that ignorant). If i take the MMC and put it back into a PC it is correctly formated and partitioned, did this like 10 times:
Put in PC check with GParted, put in SOM (in the slot for MMC) and obtained same msg again. retired MMC conected to PC and Again the MMC is correct as "msdos and ext2 format".
blue_z wrote: Do you know what fdisk is?
What makes you think you need it?
Fdisk is not part of the kernel; it's a userspace program.
Most of the guides, information and ways of detecting the MMC into embedded linux make use of fdisk. It COULD help me, unless you think it wont. What you suggest?
blue_z wrote:Stop referring to "SD".
There is no device called "SD" or Secure Digital.
When i got to thsi i had to change all SD uses in my responses to MMC, i believe this is more accurate. Thanks.

Regards

Re: Implementing SD in Linux for SAM9x35

Posted: Fri Jun 21, 2019 11:16 pm
by blue_z
AleFachini wrote: If i take the MMC and put it back into a PC it is correctly formated and partitioned, did this like 10 times:
Put in PC check with GParted, put in SOM (in the slot for MMC) and obtained same msg again. retired MMC conected to PC and Again the MMC is correct as "msdos and ext2 format".
Seems like the only verification you tried is with the same utility used for partitioning and formatting.

Why haven't you verified the SD card on the Linux PC in the same manner that you would use that SD card on the SBC?
IOW try to mount a filesystem (on the SD card), and then access its files.

AleFachini wrote: Most of the guides, information and ways of detecting the MMC into embedded linux make use of fdisk. It COULD help me, unless you think it wont. What you suggest?
If you (actually) verify the partitioning and formatting of the SD card by using it on the PC (i.e. mounting the SD card), then having/using fdisk on the SBC has IMO no utility.

AleFachini wrote: When i got to thsi i had to change all SD uses in my responses to MMC,
You are not using a "SD" nor "MMC". It's a SD card.
There is no acronym for this medium.

Regards

Re: Implementing SD in Linux for SAM9x35

Posted: Mon Jun 24, 2019 4:38 pm
by AleFachini
blue_z wrote: Seems like the only verification you tried is with the same utility used for partitioning and formatting.

Why haven't you verified the SD card on the Linux PC in the same manner that you would use that SD card on the SBC?
IOW try to mount a filesystem (on the SD card), and then access its files.
Ok i tried this from console in Ubuntu:
root@afachini:/# fdisk -l

[SECTION REMOVED FOR SIMPLICITY]

SD Card its detected in Ubuntu
Disk /dev/sdb: 14,5 GiB, 15590227968 bytes, 30449664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9162adf4

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 30449663 30447616 14,5G 83 Linux
root@afachini:/# fdisk /dev/sdb

I will delete partition and start from zero

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30449663, default 2048): 2048
Last sector, +sectors or +size{K,M,G,T,P} (2048-30449663, default 30449663): 30449663

Created a new partition 1 of type 'Linux' and of size 14,5 GiB.
Partition #1 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): w
The partition table has been altered.
Syncing disks.

root@afachini:/# mkfs.vfat -F 32 /dev/sdb1
mkfs.fat 4.1 (2017-01-24)
mkfs.vfat: /dev/sdb1 contains a mounted filesystem.
root@afachini:/# umount /dev/sdb1

I will format the sd partition with vfat which is suported because i checked cat /proc/filesystems
root@afachini:/# mkfs.vfat -F 32 /dev/sdb1
mkfs.fat 4.1 (2017-01-24)
root@afachini:/# fdisk -l

[SECTION REMOVED FOR SIMPLICITY]

I now list again to see if my devices is correctly partitioned and formated
Disk /dev/sdb: 14,5 GiB, 15590227968 bytes, 30449664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9162adf4

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 30449663 30447616 14,5G 83 Linux

Mounting device
root@afachini:/# mount /dev/sdb1 /mnt/sdfs

Listing files inside mounted device, It is empty
root@afachini:/# ls /dev/sdb1
/dev/sdb1
Listing blocks to check the TYPE
root@afachini:/# blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sr0: UUID="2011-08-15-14-56-28-00" LABEL="VBOXADDITIONS_4.1.2_73507" TYPE="iso9660"
/dev/sda1: UUID="776d3f86-d4f1-4e82-99c5-63ea22ae124e" TYPE="ext4" PARTUUID="bfd47dc6-01"
/dev/sda5: UUID="f18f68cc-bce3-4a8a-98e0-3deff8b51e8c" TYPE="swap" PARTUUID="bfd47dc6-05"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/sdb1: UUID="1799-5678" TYPE="vfat" PARTUUID="9162adf4-01"
root@afachini:/#
Then i used the SD card to save and open a text file but i did this from ubuntu GUI.
Now, this is the way i think i should do it in my SOM's embedded kernel.

blue_z wrote: If you (actually) verify the partitioning and formatting of the SD card by using it on the PC (i.e. mounting the SD card), then having/using fdisk on the SBC has IMO no utility.
I am sorry, what does SBC mean?
blue_z wrote: You are not using a "SD" nor "MMC". It's a SD card.
There is no acronym for this medium.
Ok i Understand, but why the linux console says mmcblk0 unkown partition? is it asigning that its a memory card? thats not clear for me.

After Posting I tried to access de SD Card again from the embedded and i still got the same result
mmcblk0 Unkown partition table
. What else should i try now?

Regards.

Re: Implementing SD in Linux for SAM9x35

Posted: Tue Jun 25, 2019 1:42 am
by blue_z
AleFachini wrote:
I now list again to see if my devices is correctly partitioned and formated
...
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 30449663 30447616 14,5G 83 Linux
You have created an inconsistency on your SD card.
The first partition has been formatted with a vfat filesystem.
But the partition table indicates that this first partition is a "Linux filesystem" (with ID 83).
The correct fdisk output should be a "W95 FAT32" filesystem (and ID is b or c instead of 83) for a vfat filesystem.
(I don't know the significance of this inconsistency, i.e. what might/will break.)

AleFachini wrote:
Mounting device
root@afachini:/# mount /dev/sdb1 /mnt/sdfs

Listing files inside mounted device, It is empty
root@afachini:/# ls /dev/sdb1
/dev/sdb1
...
Then i used the SD card to save and open a text file but i did this from ubuntu GUI.
That's a valid mount command, but you are not accessing the mounted filesystem.
That second command merely lists the device node rather than the mount point (i.e. the filesystem on SD card).
You have not shown that the filesystem is empty.

Your claim of having "used the SD card to save and open a text file" is not substantiated with any terminal/console log.
Combined with the fact that you confuse the device node with the mount point, I see no verification that you have a properly formatted SD card.
(A thorough verification would perform unmount and/or eject the SD card between major steps.)


AleFachini wrote: I am sorry, what does SBC mean?
Single Board Computer.
A generic term that can be used for what you incorrectly refer to as "the embedded" (i.e. "embedded" is an adjective, rather than a noun).

AleFachini wrote: Ok i Understand, but why the linux console says mmcblk0 unkown partition? is it asigning that its a memory card? thats not clear for me.
That is a correct block device name for a SD card.

AleFachini wrote: After Posting I tried to access de SD Card again from the embedded and i still got the same result
mmcblk0 Unkown partition table
. What else should i try now?
Perform a sanity test with a downloaded SD card image from Linux4SAM.
The first partition will be a 16 MB vfat (FAT16) partition.

Regards

Re: Implementing SD in Linux for SAM9x35

Posted: Tue Jun 25, 2019 6:26 pm
by AleFachini
blue_z wrote: You have created an inconsistency on your SD card.
The first partition has been formatted with a vfat filesystem.
But the partition table indicates that this first partition is a "Linux filesystem" (with ID 83).
The correct fdisk output should be a "W95 FAT32" filesystem (and ID is b or c instead of 83) for a vfat filesystem.
(I don't know the significance of this inconsistency, i.e. what might/will break.)
You are correct!, I tried this now:
root@afachini:/home/afachini# findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,relatime,errors=rem
├─/sys sysfs sysfs rw,nosuid,nodev,noexec
│ ├─/sys/kernel/security securityfs securit rw,nosuid,nodev,noexec
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/unified cgroup cgroup2 rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec
│ │ └─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec
│ ├─/sys/kernel/debug debugfs debugfs rw,relatime
│ └─/sys/fs/fuse/connections fusectl fusectl rw,relatime
├─/proc proc proc rw,nosuid,nodev,noexec
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=25,pgrp
├─/dev udev devtmpf rw,nosuid,relatime,siz
│ ├─/dev/pts devpts devpts rw,nosuid,noexec,relat
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev
│ ├─/dev/hugepages hugetlbfs hugetlb rw,relatime
│ └─/dev/mqueue mqueue mqueue rw,relatime
├─/run tmpfs tmpfs rw,nosuid,noexec,relat
│ ├─/run/lock tmpfs tmpfs rw,nosuid,nodev,noexec
│ ├─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relati
│ │ └─/run/user/1000/gvfs gvfsd-fuse fuse.gv rw,nosuid,nodev,relati
│ └─/run/user/0 tmpfs tmpfs rw,nosuid,nodev,relati
├─/snap/gnome-3-28-1804/59 /dev/loop0 squashf ro,nodev,relatime
├─/snap/gnome-calculator/406 /dev/loop1 squashf ro,nodev,relatime
├─/snap/gnome-logs/61 /dev/loop2 squashf ro,nodev,relatime
├─/snap/core18/1013 /dev/loop3 squashf ro,nodev,relatime
├─/snap/core18/970 /dev/loop4 squashf ro,nodev,relatime
├─/snap/gnome-3-28-1804/55 /dev/loop5 squashf ro,nodev,relatime
├─/snap/gnome-characters/288 /dev/loop6 squashf ro,nodev,relatime
├─/snap/gnome-system-monitor/91 /dev/loop7 squashf ro,nodev,relatime
├─/snap/gnome-3-26-1604/88 /dev/loop8 squashf ro,nodev,relatime
├─/snap/gnome-system-monitor/87 /dev/loop9 squashf ro,nodev,relatime
├─/snap/core/7169 /dev/loop10 squashf ro,nodev,relatime
├─/snap/gtk-common-themes/1198 /dev/loop11 squashf ro,nodev,relatime
├─/snap/core/6964 /dev/loop12 squashf ro,nodev,relatime
├─/snap/gnome-3-26-1604/86 /dev/loop13 squashf ro,nodev,relatime
├─/snap/gnome-characters/284 /dev/loop14 squashf ro,nodev,relatime
└─/mnt/sdfs /dev/sdb1 vfat rw,relatime,fmask=0022
root@afachini:/home/afachini# ls /mnt/sdfs
'SD ubuntu.txt' 'System Volume Information'


root@afachini:/mnt# blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda1: UUID="776d3f86-d4f1-4e82-99c5-63ea22ae124e" TYPE="ext4" PARTUUID="bfd47dc6-01"
/dev/sda5: UUID="f18f68cc-bce3-4a8a-98e0-3deff8b51e8c" TYPE="swap" PARTUUID="bfd47dc6-05"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/sdb1: UUID="1799-5678" TYPE="vfat" PARTUUID="9162adf4-01"
From this commands the format it is vfat, and also i can acced the SD card in windows too.


Its seems the problem its in my SBC kernel.
blue_z wrote: Perform a sanity test with a downloaded SD card image from Linux4SAM.
The first partition will be a 16 MB vfat (FAT16) partition.
Will try this and report back later.

thank you!