On Wed, Oct 30, 2024 at 11:33 AM Matteo Golin <matteo.go...@gmail.com>
wrote:

> Hi Alan,
>
> This makes sense, but I guess the SD card must be formatted in advance for
> the "parse_block_partition" to detect and register the partitions as
> "/dev/mmcsd0p0" and "/dev/mmcsd0p1"? In my use case I was hoping to have
> this work on a blank SD card.
>
> I was hoping to format a completely unformatted SD card into two partitions
> in NuttX (when the first time the system is booted with a fresh SD).


you can issue mkgpt or mkmbr from nsh:
https://github.com/apache/nuttx-apps/tree/master/fsutils/mkgpt
https://github.com/apache/nuttx-apps/tree/master/fsutils/mkmbr


> I've
> only seen it done with the forceformat option to nx_mount(), but I think
> that will always format the entire block device (unless called on the
> individual partition itself like mmcsd0p0, but then it's chicken before the
> egg scenario). I don't suppose NuttX has any other formatting API that I'm
> missing?
>
>
The partition format can be done by a userspace program like aboving,
that's why nuttx kernel only contains the parse code, not format code.


> Thank you for all your help,
>
> Matteo
>
> On Tue, Oct 29, 2024, 5:46 PM Alan C. Assis <acas...@gmail.com> wrote:
>
> > Hi Matteo,
> >
> > If the /dev/mmc0pX were created you can format it from the NSH> command
> > line.
> >
> > BR,
> >
> > Alan
> >
> > On Tue, Oct 29, 2024 at 6:17 PM Matteo Golin <matteo.go...@gmail.com>
> > wrote:
> >
> > > While we try to get that working, this would require that the SD card
> be
> > > formatted in advance, right? I would imagine we could possibly
> pre-format
> > > two FAT partitions, load both partitions and then re-format one of them
> > to
> > > be littlefs (since littlefs formatting from a host computer is
> > non-trivial
> > > as far as I'm aware). Since we want 1 littlefs and 1 FAT partition.
> Does
> > > NuttX have a better way to format an SD into two partitions via an
> > internal
> > > API, similar to how you can call `nx_mount` with "forceformat" to
> > re-format
> > > an entire block device?
> > >
> > > Thank you so much for your help,
> > > Matteo
> > >
> > > On Tue, Oct 29, 2024 at 12:45 AM Xiang Xiao <xiaoxiang781...@gmail.com
> >
> > > wrote:
> > >
> > > > On Tue, Oct 29, 2024 at 10:02 AM Jia Lin <jia89...@gmail.com> wrote:
> > > >
> > > > > On 2024/10/26 05:27:35 Xiang Xiao wrote:
> > > > > > have you enable CONFIG_GPT_PARTITION or CONFIG_MBR_PARTITION and
> > > > > > call parse_block_partition:
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/apache/nuttx/blob/master/include/nuttx/fs/partition.h#L81
> > > > > > to register partitions as block devices again, so you can mount
> the
> > > > > > different file systems on these new block devices.
> > > > > >
> > > > > > Thanks
> > > > > > Xiang
> > > > > >
> > > > > > On Sat, Oct 26, 2024 at 4:51 AM Matteo Golin <ma...@gmail.com>
> > > wrote:
> > > > > >
> > > > > > > I got my hands on a SPI SD card adapter and managed to try out
> > > SD/MMC
> > > > > > > support for it through NuttX on my Pico. FAT file
> > > > > > > systems worked with no problem, and after a little configuring
> I
> > > > > managed
> > > > > > > to get littlefs going as well.
> > > > > > >
> > > > > > > Now I'm wondering if NuttX has support for multiple partitions
> on
> > > the
> > > > > same
> > > > > > > device; I'm hoping I can take a 32GB micro-SD
> > > > > > > card and have 16GB be littlefs and 16GB be vfat. I haven't been
> > > able
> > > > to
> > > > > > > find any documentation about this though, and
> > > > > > > after formatting my SD card to have two vfat partitions I can
> see
> > > > that
> > > > > > > NuttX is only able to mount the first one.
> > > > > > >
> > > > > > > I managed briefly to get both partitions on one card by first
> > > > > formatting
> > > > > > > the card as littlefs, then using fdisk on my
> > > > > > > host computer to add a vfat partition starting halfway through
> > the
> > > > > card,
> > > > > > > and then was able to mount both on NuttX as two
> > > > > > > distinct file systems. Unfortunately after putting files on
> them,
> > > > > > > rebooting NuttX and trying to remount, the vfat
> > > > > > > partition was corrupted.
> > > > > > >
> > > > > > > Has anyone managed to get multiple partitions to work? How
> would
> > I
> > > go
> > > > > > > about it?
> > > > > > >
> > > > > > > Matteo
> > > > > > >
> > > > > >
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I work with Matteo on CUInspace and am currently trying to get
> Nuttx
> > to
> > > > > recognize two partitions on a SD card. Currently I'm a little
> > confused
> > > on
> > > > > how to use / implement parse_block_partition. I did find a previous
> > > > thread
> > > > > on a similar subject (
> > > > > https://lists.apache.org/thread/q19rdvst6k687s4v045q362j68r2so1t
> > > > > <(https://lists.apache.org/thread/q19rdvst6k687s4v045q362j68r2so1t
> > >),
> > > > but
> > > > > I
> > > > > am a bit lost trying to follow the code, specifically on where
> would
> > be
> > > > the
> > > > > best place to call parse_block_partition. If anyone has any
> > experience
> > > > with
> > > > > mounting an SD card with multiple partitions any help would be
> > > > appreciated!
> > > > >
> > > > >
> > > > If the card is inserted physically, you can call
> parse_block_partition
> > in
> > > > board initialization like:
> > > >
> > > >
> > >
> >
> https://github.com/apache/nuttx/blob/master/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c#L74
> > > > if the card is inserted dynamically, you may need insert the call in
> > > > automount:
> > > > https://github.com/apache/nuttx/blob/master/fs/mount/fs_automount.c
> > > >
> > > >
> > > >
> > > > > Thanks,
> > > > > Tony
> > > > >
> > > >
> > >
> >
>

On Wed, Oct 30, 2024 at 11:33 AM Matteo Golin <matteo.go...@gmail.com>
wrote:

> Hi Alan,
>
> This makes sense, but I guess the SD card must be formatted in advance for
> the "parse_block_partition" to detect and register the partitions as
> "/dev/mmcsd0p0" and "/dev/mmcsd0p1"? In my use case I was hoping to have
> this work on a blank SD card.
>
> I was hoping to format a completely unformatted SD card into two partitions
> in NuttX (when the first time the system is booted with a fresh SD). I've
> only seen it done with the forceformat option to nx_mount(), but I think
> that will always format the entire block device (unless called on the
> individual partition itself like mmcsd0p0, but then it's chicken before the
> egg scenario). I don't suppose NuttX has any other formatting API that I'm
> missing?
>
> Thank you for all your help,
>
> Matteo
>
> On Tue, Oct 29, 2024, 5:46 PM Alan C. Assis <acas...@gmail.com> wrote:
>
> > Hi Matteo,
> >
> > If the /dev/mmc0pX were created you can format it from the NSH> command
> > line.
> >
> > BR,
> >
> > Alan
> >
> > On Tue, Oct 29, 2024 at 6:17 PM Matteo Golin <matteo.go...@gmail.com>
> > wrote:
> >
> > > While we try to get that working, this would require that the SD card
> be
> > > formatted in advance, right? I would imagine we could possibly
> pre-format
> > > two FAT partitions, load both partitions and then re-format one of them
> > to
> > > be littlefs (since littlefs formatting from a host computer is
> > non-trivial
> > > as far as I'm aware). Since we want 1 littlefs and 1 FAT partition.
> Does
> > > NuttX have a better way to format an SD into two partitions via an
> > internal
> > > API, similar to how you can call `nx_mount` with "forceformat" to
> > re-format
> > > an entire block device?
> > >
> > > Thank you so much for your help,
> > > Matteo
> > >
> > > On Tue, Oct 29, 2024 at 12:45 AM Xiang Xiao <xiaoxiang781...@gmail.com
> >
> > > wrote:
> > >
> > > > On Tue, Oct 29, 2024 at 10:02 AM Jia Lin <jia89...@gmail.com> wrote:
> > > >
> > > > > On 2024/10/26 05:27:35 Xiang Xiao wrote:
> > > > > > have you enable CONFIG_GPT_PARTITION or CONFIG_MBR_PARTITION and
> > > > > > call parse_block_partition:
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/apache/nuttx/blob/master/include/nuttx/fs/partition.h#L81
> > > > > > to register partitions as block devices again, so you can mount
> the
> > > > > > different file systems on these new block devices.
> > > > > >
> > > > > > Thanks
> > > > > > Xiang
> > > > > >
> > > > > > On Sat, Oct 26, 2024 at 4:51 AM Matteo Golin <ma...@gmail.com>
> > > wrote:
> > > > > >
> > > > > > > I got my hands on a SPI SD card adapter and managed to try out
> > > SD/MMC
> > > > > > > support for it through NuttX on my Pico. FAT file
> > > > > > > systems worked with no problem, and after a little configuring
> I
> > > > > managed
> > > > > > > to get littlefs going as well.
> > > > > > >
> > > > > > > Now I'm wondering if NuttX has support for multiple partitions
> on
> > > the
> > > > > same
> > > > > > > device; I'm hoping I can take a 32GB micro-SD
> > > > > > > card and have 16GB be littlefs and 16GB be vfat. I haven't been
> > > able
> > > > to
> > > > > > > find any documentation about this though, and
> > > > > > > after formatting my SD card to have two vfat partitions I can
> see
> > > > that
> > > > > > > NuttX is only able to mount the first one.
> > > > > > >
> > > > > > > I managed briefly to get both partitions on one card by first
> > > > > formatting
> > > > > > > the card as littlefs, then using fdisk on my
> > > > > > > host computer to add a vfat partition starting halfway through
> > the
> > > > > card,
> > > > > > > and then was able to mount both on NuttX as two
> > > > > > > distinct file systems. Unfortunately after putting files on
> them,
> > > > > > > rebooting NuttX and trying to remount, the vfat
> > > > > > > partition was corrupted.
> > > > > > >
> > > > > > > Has anyone managed to get multiple partitions to work? How
> would
> > I
> > > go
> > > > > > > about it?
> > > > > > >
> > > > > > > Matteo
> > > > > > >
> > > > > >
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I work with Matteo on CUInspace and am currently trying to get
> Nuttx
> > to
> > > > > recognize two partitions on a SD card. Currently I'm a little
> > confused
> > > on
> > > > > how to use / implement parse_block_partition. I did find a previous
> > > > thread
> > > > > on a similar subject (
> > > > > https://lists.apache.org/thread/q19rdvst6k687s4v045q362j68r2so1t
> > > > > <(https://lists.apache.org/thread/q19rdvst6k687s4v045q362j68r2so1t
> > >),
> > > > but
> > > > > I
> > > > > am a bit lost trying to follow the code, specifically on where
> would
> > be
> > > > the
> > > > > best place to call parse_block_partition. If anyone has any
> > experience
> > > > with
> > > > > mounting an SD card with multiple partitions any help would be
> > > > appreciated!
> > > > >
> > > > >
> > > > If the card is inserted physically, you can call
> parse_block_partition
> > in
> > > > board initialization like:
> > > >
> > > >
> > >
> >
> https://github.com/apache/nuttx/blob/master/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c#L74
> > > > if the card is inserted dynamically, you may need insert the call in
> > > > automount:
> > > > https://github.com/apache/nuttx/blob/master/fs/mount/fs_automount.c
> > > >
> > > >
> > > >
> > > > > Thanks,
> > > > > Tony
> > > > >
> > > >
> > >
> >
>

Reply via email to