Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not mount Raspberry Pi Pico #41

Closed
probonopd opened this issue Mar 28, 2022 · 9 comments
Closed

Does not mount Raspberry Pi Pico #41

probonopd opened this issue Mar 28, 2022 · 9 comments

Comments

@probonopd
Copy link

When attaching a Raspberry Pi Pico with the BOOTSEL button held down, there should be a USB storage device mounted so that the user can copy the firmware there.

But no drive is mounted by automount.

dmesg says:

ugen5.2: <Raspberry Pi RP2 Boot> at usbus5
umass1 on uhub3
umass1: <Raspberry Pi RP2 Boot, class 0/0, rev 1.10/1.00, addr 2> on usbus5
umass1:  SCSI over Bulk-Only; quirks = 0x0100
umass1:9:1: Attached to scbus9
da1 at umass-sim1 bus 1 scbus9 target 0 lun 0
da1: <RPI RP2 2> Removable Direct Access SCSI-2 device
da1: Serial Number ...
da1: 1.000MB/s transfers
da1: 128MB (262144 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>
GEOM_LABEL[1]: MSDOSFS: da1: no FAT volume detected.
GEOM_LABEL[1]: Label for provider da1 is diskid/DISK-...
GEOM_LABEL[1]: MSDOSFS: da1s1: no FAT signature found.

geom list disk says:

Geom name: da1
Providers:
1. Name: da1
   Mediasize: 134217728 (128M)
   Sectorsize: 512
   Mode: r0w0e0
   descr: RPI RP2
   ident: ...
   rotationrate: unknown
   fwsectors: 32
   fwheads: 64

cat /var/log/automount.log says:

/dev/da1: attach
/dev/da1s1: attach
/dev/da1: not a block device
/dev/da1s1: not a block device
FreeBSD% file /dev/da1s1
/dev/da1s1: character special (1/18)
FreeBSD% sudo camcontrol devlist
...
<RPI RP2 2>                        at scbus9 target 0 lun 0 (pass4,da1)
FreeBSD% gpart show da1
=>     1  262143  da1  MBR  (128M)
       1  262143    1  !14  (128M)
FreeBSD% dd if=/dev/da1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -1  
MSWIN4.1

FreeBSD% dd if=/dev/da1s1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -1 
MSWIN4.1

FreeBSD% file -k -r -b -L -s /dev/da1s1 2> /dev/null | sed -E 's/label:\ \".*\"//g'
DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSWIN4.1", sectors/cluster 8, root entries 512, Media descriptor 0xf8, sectors/FAT 129, sectors/track 1, heads 1, hidden sectors 1, sectors 262143 (volumes > 32 MB), serial number 0x1a885a, , FAT (16 bit) DOS executable (COM)
-  (Lepton 2.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000
-  (Lepton 3.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 	0.000000
- data

Mounting like this manually works:

FreeBSD% sudo mount -t msdosfs /dev/da1s1 /mnt
FreeBSD% ls /mnt
INDEX.HTM       INFO_UF2.TXT

Not sure what is going on. Maybe the device is not fast enough and something needs more time?

How to debug this best?

@vermaden
Copy link
Owner

This is the test that writes not a block device in the log file:

# FUNCTION: check if device is a block device
__check_block_device() { # 1=DEV
  # first check if its block device
  if ! fstyp ${1} 1> /dev/null 2>&1
  then
    __log "${DEV}: not a block device"
    exit 0
  fi
}

Can you give me output of these below?

fstyp /dev/da1
echo ${?}
fstyp /dev/da1s1
echo ${?}

Thanks.

@probonopd
Copy link
Author

fstyp: /dev/da1: filesystem not recognized
1
fstyp: /dev/da1s1: filesystem not recognized
1

@probonopd
Copy link
Author

probonopd commented Mar 28, 2022

truss output makes me wonder whether fstyp doesn't like the MSWIN4.1 or otherwise cannot read something:

...
lseek(4,0x8000,SEEK_SET)                         = 32768 (0x8000)
read(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
lseek(4,0x0,SEEK_SET)                            = 0 (0x0)
read(4,"\M-k<\M^PMSWIN4.1\0\^B\b\^A\0\^B"...,4096) = 4096 (0x1000)
lseek(4,0x400,SEEK_SET)                          = 1024 (0x400)
read(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
lseek(4,0x400,SEEK_SET)                          = 1024 (0x400)
read(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
lseek(4,0x0,SEEK_SET)                            = 0 (0x0)
read(4,"\M-k<\M^PMSWIN4.1\0\^B\b\^A\0\^B"...,4096) = 4096 (0x1000)
lseek(4,0x0,SEEK_SET)                            = 0 (0x0)
read(4,"\M-k<\M^PMSWIN4.1\0\^B\b\^A\0\^B"...,4096) = 4096 (0x1000)
pread(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,8192,0x10000) = 8192 (0x2000)
pread(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,8192,0x2000) = 8192 (0x2000)
pread(4,"\M-k<\M^PMSWIN4.1\0\^B\b\^A\0\^B"...,8192,0x0) = 8192 (0x2000)
pread(4,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,8192,0x40000) = 8192 (0x2000)
fstyp: write(2,"fstyp: ",7)                              = 7 (0x7)
/dev/da0s1: filesystem not recognizedwrite(2,"/dev/da1s1: filesystem not recog"...,37) = 37 (0x25)

write(2,"\n",1)                                  = 1 (0x1)
getpid()                                         = 5023 (0x139f)
exit(0x1)
process exit, rval = 1

@vermaden
Copy link
Owner

fstyp: /dev/da1: filesystem not recognized
1
fstyp: /dev/da1s1: filesystem not recognized
1

So with this in mind you should submit a bug on FreeBSD to make sure fstyp(8) works and detects filesystem on that platform/architecture you use.

In the past I tried to detect it myself with file(1) and dd(8) and strings(1) commands ... but moved to fstyp(1) as it was more reliable. Seems its not true for all architectures ...

Be fast ... maybe the needed fix will make its way to upcoming 13.1-RELEASE version :)

Regards.

@probonopd
Copy link
Author

FreeBSD% dd if=/dev/da1s1 of=/tmp/partition1.dd
1737+0 records in
1737+0 records out
889344 bytes transferred in 10.468566 secs (84954 bytes/sec)
FreeBSD% dd if=/dev/da0s1 of=/tmp/partition1.dd bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes transferred in 0.992788 secs (1056193 bytes/sec)

FreeBSD% file /tmp/partition1.dd 
/tmp/partition1.dd: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSWIN4.1", sectors/cluster 8, root entries 512, Media descriptor 0xf8, sectors/FAT 129, sectors/track 1, heads 1, hidden sectors 1, sectors 262143 (volumes > 32 MB), serial number ..., label: "RPI-RP2    ", FAT (16 bit)

FreeBSD% fstyp /tmp/partition1.dd
fstyp: /tmp/partition1.dd: filesystem not recognized

Attached is the dd dump.

partition1.zip

@probonopd
Copy link
Author

@vermaden
Copy link
Owner

Thank you.

@probonopd
Copy link
Author

Thanks for your help in finding the root cause.

@emaste
Copy link

emaste commented Mar 28, 2022

https://reviews.freebsd.org/D34699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants