Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Dec 2021 13:00:38 -0800
From:      Mark Millard via freebsd-arm <freebsd-arm@freebsd.org>
To:        bob prohaska <fbsd@www.zefox.net>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Hot-plugging microSD on Raspberry Pi under FreeBSD
Message-ID:  <91D4CF6B-5690-413D-A873-2DB50CAF9637@yahoo.com>
In-Reply-To: <20211226192338.GA16188@www.zefox.net>
References:  <20211226192338.GA16188@www.zefox.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2021-Dec-26, at 11:23, bob prohaska <fbsd@www.zefox.net> wrote:

> Are there any special protocols to observe when hot-plugging
> microSD cards on Raspberry Pi when FreeBSD is up and running?
> Electrically it's claimed to be ok in this thread by one "jdb":
> https://forums.raspberrypi.com/viewtopic.php?t=3D281249
> so I'm asking about how the FreeBSD software might react.=20
>=20
> Obviously filesystems have to be gracefully unmounted, but is
> that all? Can the kernel be "aware" of an unused device and
> get confused if it goes away?

As I remember, for FreeBSD,

A) The built-in microsd card slot works fine for swapping
   media that are not mounted at the time.

but, for example (no mounts involved, RPi4B 8GiByte test context),

B.0) Plug-in the USB reader, no media present. (USB3 example here.)
B.1) Insert a 128 GiByte media to the reader.
B.2) Remove that media.
B.3) Insert a 32 GiByte media to the reader
     (same slot in the reader).

Result:

(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af c1 00 00 04 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af fe 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af fe 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
(da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00=20
(da4:umass-sim1:1:0:3): CAM status: SCSI Status Error
(da4:umass-sim1:1:0:3): SCSI status: Check Condition
(da4:umass-sim1:1:0:3): SCSI sense: ILLEGAL REQUEST asc:21,0 (Logical =
block address out of range)
(da4:umass-sim1:1:0:3): Error 22, Unretryable error
GEOM_PART: da4 was automatically resized.
  Use `gpart commit da4` to save changes or `gpart undo da4` to revert =
them.
GEOM_PART: da4 was automatically resized.
  Use `gpart commit da4` to save changes or `gpart undo da4` to revert =
them.
GEOM_PART: da4 was automatically resized.
  Use `gpart commit da4` to save changes or `gpart undo da4` to revert =
them.
GEOM_PART: da4 was automatically resized.
  Use `gpart commit da4` to save changes or `gpart undo da4` to revert =
them.
GEOM_PART: da4 was automatically resized.
  Use `gpart commit da4` to save changes or `gpart undo da4` to revert =
them.

If you do the 32 GiByte first instead, then for the 128 GiByte you
get notices from GEOM_PART about "was automatically resized"
but it does not "address out of range".

I expect that swapping two media of the same capacity would
be less likely to generate any messages, but that does not
mean that such a swap would be handled fully correctly.

So I unplug the whole reader to swap media. This is messier
if multiple slots are in use (more unmounts and later
remounts).

I expect that this is a FreeBSD issue, not a RPi4B
issue. But I've not tested such under Fedora or the
like or (recently) on a Rock64 or other such.

=3D=3D=3D
Mark Millard
marklmi at yahoo.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?91D4CF6B-5690-413D-A873-2DB50CAF9637>