public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
@ 2024-03-29  8:21 John Chew
  2024-03-29 22:10 ` Andrew Fish via groups.io
  0 siblings, 1 reply; 11+ messages in thread
From: John Chew @ 2024-03-29  8:21 UTC (permalink / raw)
  To: devel


[-- Attachment #1.1: Type: text/plain, Size: 949 bytes --]

Hi everyone,

I have enabled the "TFTP" command and for it to work, it requires a filesystem. I'm using the following module:

ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf

Since my platform does not have any storage driver available yet (e.g. MMC, SPI, PCIE, USB), I'm creating a virtual disk in my RAM using the following module:

MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf

However, I couldn't figure out a way to create a file system in the virtual disk.

Is there a way to create a filesystem in the virtual disk?

Thanks!

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117232): https://edk2.groups.io/g/devel/message/117232
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #1.2: Type: text/html, Size: 1686 bytes --]

[-- Attachment #2: dummyfile.0.part --]
[-- Type: image/png, Size: 276541 bytes --]

[-- Attachment #3: dummyfile.1.part --]
[-- Type: image/png, Size: 11320 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-03-29  8:21 [edk2-devel] Is there a way to create filesystem in UEFI Shell ? John Chew
@ 2024-03-29 22:10 ` Andrew Fish via groups.io
  2024-03-30  0:16   ` Michael D Kinney
  2024-04-01  3:39   ` John Chew
  0 siblings, 2 replies; 11+ messages in thread
From: Andrew Fish via groups.io @ 2024-03-29 22:10 UTC (permalink / raw)
  To: devel, yuinyee.chew

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf is a virtual storage device, so it just emulates an unformatted disk. You would need to partition or initialize the file system given you have a RAM disk. 

The file system driver lives here: https://github.com/tianocore/edk2/tree/master/FatPkg/EnhancedFatDxe

The ArmPkg has a driver that lets you do a file system over JTAG: https://github.com/tianocore/edk2/blob/master/ArmPkg/Filesystem/SemihostFs/Arm/

You can make a ReadOnly file system out of contents on an FV (Firmware Volume): https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Universal/FvSimpleFileSystemDxe
FV is defined in the PI Spec as a layout for flash that contains files, but no directories. 

Thanks,

Andrew Fish

> On Mar 29, 2024, at 1:21 AM, John Chew <yuinyee.chew@starfivetech.com> wrote:
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117245): https://edk2.groups.io/g/devel/message/117245
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 2794 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-03-29 22:10 ` Andrew Fish via groups.io
@ 2024-03-30  0:16   ` Michael D Kinney
  2024-04-01  3:43     ` John Chew
  2024-04-01  3:39   ` John Chew
  1 sibling, 1 reply; 11+ messages in thread
From: Michael D Kinney @ 2024-03-30  0:16 UTC (permalink / raw)
  To: devel, afish, yuinyee.chew; +Cc: Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 1710 bytes --]

There are also utilities to partition and format.

https://www.intel.com/content/www/us/en/download/714351/uefi-shell-disk-utilities.html

Mike

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via groups.io
Sent: Friday, March 29, 2024 3:11 PM
To: devel@edk2.groups.io; yuinyee.chew@starfivetech.com
Subject: Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?

MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf is a virtual storage device, so it just emulates an unformatted disk. You would need to partition or initialize the file system given you have a RAM disk.

The file system driver lives here: https://github.com/tianocore/edk2/tree/master/FatPkg/EnhancedFatDxe

The ArmPkg has a driver that lets you do a file system over JTAG: https://github.com/tianocore/edk2/blob/master/ArmPkg/Filesystem/SemihostFs/Arm/

You can make a ReadOnly file system out of contents on an FV (Firmware Volume): https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Universal/FvSimpleFileSystemDxe
FV is defined in the PI Spec as a layout for flash that contains files, but no directories.

Thanks,

Andrew Fish


On Mar 29, 2024, at 1:21 AM, John Chew <yuinyee.chew@starfivetech.com<mailto:yuinyee.chew@starfivetech.com>> wrote:

[cid:attach_0_17C12E88E9BAF705_29633@groups.io]




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117247): https://edk2.groups.io/g/devel/message/117247
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 5801 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-03-29 22:10 ` Andrew Fish via groups.io
  2024-03-30  0:16   ` Michael D Kinney
@ 2024-04-01  3:39   ` John Chew
  2024-04-01 15:07     ` Andrew Fish via groups.io
  1 sibling, 1 reply; 11+ messages in thread
From: John Chew @ 2024-04-01  3:39 UTC (permalink / raw)
  To: Andrew Fish, devel

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

On Sat, Mar 30, 2024 at 06:10 AM, Andrew Fish wrote:

> 
> You can make a ReadOnly file system out of contents on an FV (Firmware
> Volume): https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Universal/FvSimpleFileSystemDxe
> 
> FV is defined in the PI Spec as a layout for flash that contains files,
> but no directories.
> 

Hi Andrew,

I forgot to mention earlier, that I'm developing for RISC-V architecture.

It seems like the semihosting lib in edk2 does not have support for RISC-V yet.

Thanks for the FvSimpleFileSystemDxe suggestion.

Actually, I'm trying to TFTP "initramfs" (1MB) and "linux.efi" (25MB) into a filesystem. So, it requires to support write to the filesystem.

Do you have other suggestions?

Thanks! =)

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117275): https://edk2.groups.io/g/devel/message/117275
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 1847 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-03-30  0:16   ` Michael D Kinney
@ 2024-04-01  3:43     ` John Chew
  2024-04-03  7:47       ` Yoshinoya
  0 siblings, 1 reply; 11+ messages in thread
From: John Chew @ 2024-04-01  3:43 UTC (permalink / raw)
  To: Michael D Kinney, devel

[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

Hi Michael,

Thanks for the tool recommendation.

However, the tools are useful for x86, arm, and IPF platforms. I'm working on a RISC-V platform.

I wanted to compile the tools for RISC-V, but the link is not found:

https://edk.tianocore.org/files/documents/16/347/file_347.dat/EDK%20Build_0_2.pdf (This link is located in ReleaseNote.txt)

Do you know if there are similar tools that can be use in RISC-V platform?

Thanks! =)

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117276): https://edk2.groups.io/g/devel/message/117276
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 1478 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-01  3:39   ` John Chew
@ 2024-04-01 15:07     ` Andrew Fish via groups.io
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Fish via groups.io @ 2024-04-01 15:07 UTC (permalink / raw)
  To: edk2-devel-groups-io, yuinyee.chew

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]



> On Mar 31, 2024, at 8:39 PM, John Chew <yuinyee.chew@starfivetech.com> wrote:
> 
> On Sat, Mar 30, 2024 at 06:10 AM, Andrew Fish wrote:
> You can make a ReadOnly file system out of contents on an FV (Firmware Volume): https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Universal/FvSimpleFileSystemDxe
> FV is defined in the PI Spec as a layout for flash that contains files, but no directories. 
> Hi Andrew,
> 
>  
> I forgot to mention earlier, that I'm developing for RISC-V architecture.
> 
> It seems like the semihosting lib in edk2 does not have support for RISC-V yet.
> 
>  
> Thanks for the FvSimpleFileSystemDxe suggestion.
> 
> Actually, I'm trying to TFTP "initramfs" (1MB) and "linux.efi" (25MB) into a filesystem. So, it requires to support write to the filesystem. 
> 
>  
> Do you have other suggestions?
> 
The source code Mike linked. I forgot the place it lived. 

I think we are really enough in the RISC-V that some older things have not been ported. It should not be that hard to port to edk2. That would probably get RISC-V working.

Thanks,

Andrew Fish

>  
> Thanks! =)
> 
> John
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117296): https://edk2.groups.io/g/devel/message/117296
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 2996 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-01  3:43     ` John Chew
@ 2024-04-03  7:47       ` Yoshinoya
  2024-04-03 12:27         ` Pedro Falcato
  2024-04-04  3:11         ` John Chew
  0 siblings, 2 replies; 11+ messages in thread
From: Yoshinoya @ 2024-04-03  7:47 UTC (permalink / raw)
  To: devel, yuinyee.chew

[-- Attachment #1: Type: text/plain, Size: 1117 bytes --]

Maybe ref to ramdisk sample, create a memory type block io device, then mount file system on it.
UEFI supports fat file system, some 3rd drivers could be added to support ext4 filesystem.
Search them on github website
















At 2024-04-01 11:43:59, "John Chew" <yuinyee.chew@starfivetech.com> wrote:

Hi Michael,

 

Thanks for the tool recommendation. 

However, the tools are useful for x86, arm, and IPF platforms. I'm working on a RISC-V platform.

I wanted to compile the tools for RISC-V, but the link is not found:

https://edk.tianocore.org/files/documents/16/347/file_347.dat/EDK%20Build_0_2.pdf (This link is located in ReleaseNote.txt)

 

Do you know if there are similar tools that can be use in RISC-V platform?

 

Thanks! =)

John

 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117347): https://edk2.groups.io/g/devel/message/117347
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 2261 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-03  7:47       ` Yoshinoya
@ 2024-04-03 12:27         ` Pedro Falcato
  2024-04-04  3:11         ` John Chew
  1 sibling, 0 replies; 11+ messages in thread
From: Pedro Falcato @ 2024-04-03 12:27 UTC (permalink / raw)
  To: devel, yoshinoyatoko; +Cc: yuinyee.chew

On Wed, Apr 3, 2024 at 8:48 AM Yoshinoya <yoshinoyatoko@163.com> wrote:
>
> Maybe ref to ramdisk sample, create a memory type block io device, then mount file system on it.
> UEFI supports fat file system, some 3rd drivers could be added to support ext4 filesystem.
> Search them on github website

EDK2 already supports ext4, you need to add
edk2-platforms/Features/Ext4Pkg to your platform. Although it doesn't
have write support and I intend to keep it this way. Everything that
was discussed in this thread is definitely stepping over the line of
what is reasonable for firmware to do (making a filesystem in UEFI?
seriously???).

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117366): https://edk2.groups.io/g/devel/message/117366
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-03  7:47       ` Yoshinoya
  2024-04-03 12:27         ` Pedro Falcato
@ 2024-04-04  3:11         ` John Chew
  2024-04-17 10:42           ` charlleygreen.work
  2024-04-17 20:30           ` Andrew Fish via groups.io
  1 sibling, 2 replies; 11+ messages in thread
From: John Chew @ 2024-04-04  3:11 UTC (permalink / raw)
  To: Yoshinoya, devel


[-- Attachment #1.1: Type: text/plain, Size: 1501 bytes --]

On Wed, Apr 3, 2024 at 03:48 PM, Yoshinoya wrote:

> 
> Maybe ref to ramdisk sample, create a memory type block io device, then
> mount file system on it.
> UEFI supports fat file system, some 3rd drivers could be added to support
> ext4 filesystem.
> Search them on github website
> 

Thanks Yoshinoya for your input. =)

I have tried to compile the filesystem into my FD image as a separate FV. Then building FV HOB with it using "BuildFvHob".

Next, using the "GetSectionFromAnyFv" to load the filesystem into buffer as follow:

Finally, create a disk with the filesystem buffer created earlier.

This works without having to create filesystem in EDK2. Instead loading it from somewhere else.

However, this method has some limitations because the maximum size of each SECTION in FFS is only 16MB.

Thus, I still couldn't TFTP Linux (~25MB) into my filesystem "FS0:"

My solution:

1. Allocate buffer

2. Populate the buffer by with100MB FAT16 header

3. Register virtual disk with the buffer

I'm able to allocate 100MB of FAT16 filesystem and TFTP Linux successfully:

Thanks everyone!!

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117400): https://edk2.groups.io/g/devel/message/117400
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #1.2: Type: text/html, Size: 2731 bytes --]

[-- Attachment #2: dummyfile.0.part --]
[-- Type: image/png, Size: 15916 bytes --]

[-- Attachment #3: dummyfile.1.part --]
[-- Type: image/png, Size: 8100 bytes --]

[-- Attachment #4: dummyfile.2.part --]
[-- Type: image/png, Size: 45655 bytes --]

[-- Attachment #5: dummyfile.3.part --]
[-- Type: image/png, Size: 87659 bytes --]

[-- Attachment #6: dummyfile.4.part --]
[-- Type: image/png, Size: 95689 bytes --]

[-- Attachment #7: dummyfile.5.part --]
[-- Type: image/png, Size: 6186 bytes --]

[-- Attachment #8: dummyfile.6.part --]
[-- Type: image/png, Size: 7499 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-04  3:11         ` John Chew
@ 2024-04-17 10:42           ` charlleygreen.work
  2024-04-17 20:30           ` Andrew Fish via groups.io
  1 sibling, 0 replies; 11+ messages in thread
From: charlleygreen.work @ 2024-04-17 10:42 UTC (permalink / raw)
  To: John Chew, devel

[-- Attachment #1: Type: text/plain, Size: 672 bytes --]

Hi, John

Can you show how do you add your FV?

[FV.MY_FV]
balabala

I cannot find a way to insert a linux.efi and initrd into FV. But I see you success.
If you are willing, your work on this post will be very meaningful. Can you write a blog with all the steps?

Thank you very much!
Charlley


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117932): https://edk2.groups.io/g/devel/message/117932
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 1128 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] Is there a way to create filesystem in UEFI Shell ?
  2024-04-04  3:11         ` John Chew
  2024-04-17 10:42           ` charlleygreen.work
@ 2024-04-17 20:30           ` Andrew Fish via groups.io
  1 sibling, 0 replies; 11+ messages in thread
From: Andrew Fish via groups.io @ 2024-04-17 20:30 UTC (permalink / raw)
  To: edk2-devel-groups-io, yuinyee.chew; +Cc: Yoshinoya

[-- Attachment #1: Type: text/plain, Size: 2126 bytes --]

FYI you can have much larger files in the newer version of the filesystem. See EFI_COMMON_SECTION_HEADER2

https://uefi.org/specs/PI/1.8A/V3_Code_Definitions.html#firmware-file-system
https://uefi.org/specs/PI/1.8A/V3_Code_Definitions.html#firmware-file-section

Thanks,

Andrew Fish

> On Apr 3, 2024, at 8:11 PM, John Chew <yuinyee.chew@starfivetech.com> wrote:
> 
> On Wed, Apr 3, 2024 at 03:48 PM, Yoshinoya wrote:
> Maybe ref to ramdisk sample, create a memory type block io device, then mount file system on it.
> UEFI supports fat file system, some 3rd drivers could be added to support ext4 filesystem.
> Search them on github website
> Thanks Yoshinoya for your input. =)
> 
>  
> I have tried to compile the filesystem into my FD image as a separate FV. Then building FV HOB with it using "BuildFvHob".
> 
> Next, using the "GetSectionFromAnyFv" to load the filesystem into buffer as follow:
> 
> <dummyfile.0.part>
> 
> Finally, create a disk with the filesystem buffer created earlier. 
> 
> <dummyfile.1.part>
> 
> This works without having to create filesystem in EDK2. Instead loading it from somewhere else.
> 
> However, this method has some limitations because the maximum size of each SECTION in FFS is only 16MB.
> 
> <dummyfile.2.part>
> 
> Thus, I still couldn't TFTP Linux (~25MB) into my filesystem "FS0:"
> 
>  
> My solution:
> 
> <dummyfile.3.part> <dummyfile.4.part>
> 
> 1. Allocate buffer
> 
> 2. Populate the buffer by with100MB FAT16 header
> 
> 3. Register virtual disk with the buffer
> 
>  
> I'm able to allocate 100MB of FAT16 filesystem and TFTP Linux successfully:
> <dummyfile.5.part>
> 
> <dummyfile.6.part>
> 
>  
> Thanks everyone!!
> 
> John
> 
>  
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117933): https://edk2.groups.io/g/devel/message/117933
Mute This Topic: https://groups.io/mt/105212723/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 4364 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-04-17 20:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29  8:21 [edk2-devel] Is there a way to create filesystem in UEFI Shell ? John Chew
2024-03-29 22:10 ` Andrew Fish via groups.io
2024-03-30  0:16   ` Michael D Kinney
2024-04-01  3:43     ` John Chew
2024-04-03  7:47       ` Yoshinoya
2024-04-03 12:27         ` Pedro Falcato
2024-04-04  3:11         ` John Chew
2024-04-17 10:42           ` charlleygreen.work
2024-04-17 20:30           ` Andrew Fish via groups.io
2024-04-01  3:39   ` John Chew
2024-04-01 15:07     ` Andrew Fish via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox