scieee AI-readable full text Open interactive document viewer

NanoBoot: A Field-Programmable Gate Array/System-on-Chip Hardware Boot Loader for IoT Devices

Ruiz de Clavijo Vázquez, Paulino; Cano Quiveu, Germán; Juan Chico, Jorge; Bellido Díaz, Manuel Jesús; Viejo Cortés, Julián; Guerrero Martos, David; Ostúa Arangüena, Enrique

Abstract

This paper presents a new boot loader scheme for embedded devices with file system support built as a hardware module. The work focuses on improving the boot loader hardware and the possibility of carrying out a full boot-up process from the dedicated on-chip hardware, using a light file system to store an operating system kernel. To do so, the new full-hardware boot loader is integrated into two Field-Programmable Gate Array (FPGA) System-on-Chip (SoC), capable of launching a Linux kernel from a formatted removable media.

Full text

Citation: Ruiz-de-Clavijo, P.; Cano-Quiveu, G.; Juan, J.; Bellido, M.J.; Viejo-Cortes, J.; Guerrero, D.; Ostua, E. NanoBoot: A Field- Programmable Gate Array/ System-on-Chip Hardware Boot Loader for IoT Devices. Electronics 2024,13, 3731. https://doi.org/ 10.3390/electronics13183731 Academic Editor: Luis Gomes Received: 25 July 2024 Revised: 13 September 2024 Accepted: 18 September 2024 Published: 20 September 2024 Copyright: © 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/). electronics Article NanoBoot: A Field-Programmable Gate Array/System-on-Chip Hardware Boot Loader for IoT Devices Paulino Ruiz-de-Clavijo , German Cano-Quiveu * , Jorge Juan , Manuel Jesus Bellido , Julian Viejo-Cortes , David Guerrero and Enrique Ostua Electronics Technology Department, E.T.S. Ingeniería Informática, University of Seville, Avda. Reina Mercedes s/n, 41012 Seville, Spain; pr[email protected] (P.R.-d.-C.); [email protected] (J.J.); [email protected] (M.J.B.); [email protected] (J.V.-C.); guerr[email protected] (D.G.); [email protected] (E.O.) *Correspondence: [email protected] Abstract: This paper presents a new boot loader scheme for embedded devices with file system support built as a hardware module. The work focuses on improving the boot loader hardware and the possibility of carrying out a full boot-up process from the dedicated on-chip hardware, using a light file system to store an operating system kernel. To do so, the new full-hardware boot loader is integrated into two Field-Programmable Gate Array (FPGA) System-on-Chip (SoC), capable of launching a Linux kernel from a formatted removable media. Keywords: boot loader; field-programmable gate array; Internet of Things; System-on-Chip; hardware ; embedded device 1. Introduction Today, some embedded systems are commonly used as Internet of Things (IoT) devices. These devices usually have limited hardware and software resources. Therefore, it is often necessary to create custom designs that optimize performance and/or area. A significant part of these devices are based on System-on-Chip designs, which are complete computer systems capable of performing complex tasks. Each SoC includes a power-on reset device, which ensures that the core and peripherals reach a known state before starting the pre-programmed firmware. According to [ 1 ], then firmware can be defined as the first code executed in an embedded system, which is stored in a Non-Volatile Memory (NVM) such as Flash or Read-Only Memory (ROM). Among the objectives of the firmware may be to provide the final standalone application software of the system (like in simple Micro-Controller Units (MCUs)), but in most cases, one of the main tasks of the firmware is to retrieve the application code from an external peripheral. In embedded systems that run a full operating system, the firmware typically works as a boot loader or fetches the boot loader from some pre-defined peripheral device. According to [ 1 ], the boot loader is an application to fetch the OS or a standalone application from an external device. Boot loaders are also used in simple embedded systems that do not run an OS. For instance, MCUs include a boot section in their non-volatile Flash memory, whose main purpose is to support firmware updates. Boot loader technology is constantly evolving to improve features such as performance [ 2 , 3 ], reliability [ 4 ], development effort [ 5 ] and portability [ 6 ]. In general, the scheme of the boot process in complex SoCs is similar to general-purpose computer systems. Initially, designs lacked the ability to update firmware, as it was stored in ROM. In such systems, only the secondary software loaded by the firmware could be customized. In this situation, the boot loader code is divided into stages, where the role of each stage is the initialization of some peripherals that are necessary to obtain the next stage from another peripheral. The firmware only implements the first stage of the boot-up Electronics 2024,13, 3731. https://doi.org/10.3390/electronics13183731 https://www.mdpi.com/journal/electronics Electronics 2024,13, 3731 2 of 19 process, which is commonly referred to as the preloader. A similar procedure is used in general-purpose computer systems, but currently the ROM-BIOS is upgradeable. The main differences in the boot-up process for MCUs, SoCs, and general-purpose computer systems are summarized in Figure 1. SoC MCU General-purpose System Preloader Power On Wait until power supply is stable PC  InitVal (reset vector) Power on self test Run built-in program (BIOS) Run built-in firmware (BROM) Run boot section Boot from preconfigured BIOS device(s) Boot from off-chip device: SDCard, Network, Flash, USB. Lookup for firmware updates Power On Reset Figure 1. Comparison of preloader boot-up steps. The majority of embedded systems based on System-on-Chip use Linux as their operating system due to its flexibility and support for a wide range of architectures. The Linux system exposes a set of well-defined system-callable subroutines to manage peripherals. These subroutines are implemented in the OS as specific device drivers for each peripheral. Over these drivers and on peripherals that can work as storage elements, file systems are built. File systems are a fundamental part of the OS and an almost mandatory requirement to run applications in most SoC solutions. The file systems store both the application programs and also the OS components in the form of executable files, libraries, configuration files, etc. Storing these resources in a file system greatly simplifies application and OS updates including most of the boot loader stages. In order for the boot loader to be able to fetch the kernel, it needs to include support to read the file system type used in the underlying device. Due to the limited resources available to the first stage of the boot loader, only simple and lightweight file systems may be read from this stage. For this reason, the old and limited File Allocation Table (FAT) file system is widely used in embedded computing systems. But FAT has important deficiencies, the most important being as follows: (1) when used on Flash memory devices, the Flash is quickly degraded, since the file metadata table is frequently updated and the same Flash pages are recurrently written; (2) FAT consistency is compromised for unfinished or failed write operations. To overcome the limitations of FAT more capable later stages of the boot loader have to be added that support more robust and complex file systems. The current performance of Flash memory has driven SoC designs to adopt it as the main mass-storage technology. Traditional limitations of Flash memory have been overcome by the addition of the so-called Flash Translation Layer (FLT). FTL is a hardware/software driver that makes Flash memory linear, appearing to the system like a disk drive that emulates a block device [ 7 ]. FTLs are present in most commercial Flash mass-storage devices [8]. This paper presents NanoBoot, a hardware boot loader which is capable of booting an OS (Linux) or a standalone application from Flash removable media (SD card) using a lightweight file system for resource-restricted IoT devices, which are modeled in this paper as SoCs implemented in Field-Programmable Gate Array chips (FPGA/SOCs). The Electronics 2024,13, 3731 3 of 19 main goal to achieve with NanoBoot is to develop a fast, full hardware, generic and open source boot loader with a small footprint capable of booting an SO or standalone application. Linux was chosen because it has become the most used OS in SoC systems, and SD cards are an adequate solution to hold the system software in an SoC because of its low cost, high availability, and easiness to provide updates and fixes along the lifetime of the product. Nevertheless, many ideas and contributions in this paper may be extended to other operating systems or storage devices. The core of NanoBoot is the NanoFS file system introduced in [ 9 ] and now extended in this work. NanoFS is a lightweight file system that is suitable for implementation in hardware due to its small footprint. The paper is organized as follows: Section 2includes some background about booting Linux on SoCs and the role of file systems in the boot-up process; Section 3describes the design and internal layout of the NanoFS file system in detail; the design of NanoBoot is developed in Section 4; Section 5details the main results of the proposed approach and compares it to the standard solutions. Conclusions are summarized in Section 6. 2. Background This paper focuses on booting a Linux system from removable Flash media. The following subsections outline some background about the different technologies involved, such as Flash media storage, FPGA SoCs, and the role of file systems in the Linux boot process. 2.1. SoC Booting from Flash Media In modern SoCs, most firmware preloaders include support for a removable storage setup mode that permits obtaining the first boot loader stage from sources such as NAND Flash, SD/TF Card, eMMC, NOR Flash, USB, etc. The most common type of removable Flash storage is NAND-based, which has certain limitations. These include large page data, asymmetric read/write times, and low write-cycle endurance. Despite the limitations, NAND Flash mass storage reduces the cost of the embedded system. Currently, most NAND Flash is manufactured with an FTL that assumes the use of a file system. Therefore, most devices include FTL features such as garbage collection and a fine-grained address translation layer to efficiently manage the Flash memory [ 8 , 10 , 11 ]. Thus, today, standard consumer-grade Flash devices are ready to drive file systems with acceptable endurance and have adequate performance to boot up an OS and act as the main storage for the OS at run-time. These devices are optimized to be used with existing file systems (e.g., FAT, ext4, NTFS, exFAT, etc.) without any modifications. In this way, the Secure Digital (SD) standard [ 12 ] of the SD Association is one of the most widely used storage devices in general consumer electronics. SD cards are supported by many SoC boot loaders and have great compatibility with desktop computers, allowing the user to update or modify the system’s software and/or data in a friendly way. For testing purposes, FPGA devices are a good choice because they are flexible and allow custom hardware and software development. Most FPGA vendors include ARM cores in their high-end products, offering a powerful and very flexible SoC platform for the development of embedded systems. There is also a range of processors that can be used on FPGA chips as soft cores: RISC-V [ 13 ], Nios [ 14 ], Microblaze [ 15 ], OpenRisc [ 16 ], Leon, OpenSparc, LowRisc, etc. Some of these processors are distributed under an open hardware license and can be synthesized on FPGA chips from different manufacturers. Since custom hardware can be included in FPGA/SOCs, these platforms offer new options for boot loader design and optimization, especially when the SoC is based on a soft-core processor. There exists the possibility to include boot-loading-specific hardware or to develop a full-hardware boot-loading solution, which is proposed later in this paper. For this work, two soft-core processors have been selected to exemplify the design and implementation of a full-hardware boot-loading solution, OpenRisc and Microblaze, since both are 32-bit microprocessors capable of running Linux. OpenRISC is an open source microprocessor developed by the OpenCores community [ 17 ], implemented using a GCC- based toolchain and written in Verilog HDL synthesizable code. Its main characteristics Electronics 2024,13, 3731 4 of 19 are as follows: 32/64-bit load/store Reduced Instruction Set Computer (RISC) architecture with 32-bit uniform-length instruction format; virtual memory support through a Memory Management Unit (MMU); internal Wishbone B3 bus [ 18 ], which is an open specification. Instead, MicroBlaze is a soft-core processor designed by AMD Inc. and distributed as Intellectual Property Core (IP Core) under a proprietary license. It is a 32-bit RISC Harvard architecture processor, and the main difference compared to OpenRISC is the internal Advanced eXtensible Interface 4 (AXI4) [ 19 ] bus used. Both microprocessors can be synthesized on mid-range AMD devices, leaving plenty of spare FPGA resources to add extra internal peripherals needed to support the Linux boot-up process from removable media. FPGA/SOC booting will be discussed in detail in Section 4. 2.2. Embedded Linux Despite the available alternatives, Linux is the preferred OS for SoC development. Although Linux was originally created to run on general-purpose computers, it is extremely flexible and configurable and supports a very wide range of computer architectures [ 20 ], making it ideal for custom embedded computing. Linux for embedded systems has some specific features compared to Linux for generalpurpose computers, especially related to the boot-up process. Embedded Linux covers a wide range of devices starting at small embedded systems with about 4 MB of ROM and 8MB of RAM [ 20 ] and a variety of custom boot loaders are available for these kinds of device. The Linux boot-up process for both general-purpose computers and embedded systems is divided into three general stages [ 21 ]: boot loader,kernel startup,user space initialization. The boot loader stage is fully dependent on the platform, and although a custom boot loader is needed for each type of hardware, once the process reaches the kernel startup stage, the boot-up process is similar on all platforms. The Linux boot loader stage for current SoCs is thoroughly described in [ 22 ] and, despite some differences, its final target always consists of launching an executable Linux kernel image that was previously fetched from an external peripheral and copied to RAM. The differences among different SoC boot loaders are in firmware capabilities and limitations. For instance, the Linux kernel image is compressed in some configurations to reduce the fetch time, and other configurations add an extra RAM disk image that is also loaded before the kernel is launched. Both decompression and RAM disk loading are extra tasks carried out by the firmware. Moreover, in a removable media setup mode, the boot loader must also include the driver to access the external massive storage, increasing the firmware footprint. Linux boot performance is highly platform-dependent, but the Linux boot process is flexible and can be optimized with multiple techniques, as introduced in [ 23 – 25 ]. In these works, the boot time is reduced by testing multiple platforms and scenarios with different configurations, but the optimization heavily depends on the scheme used, with or without RAM disk. For both boot-up schemes, the boot loader stage is divided into multiple substages heavily dependent on the hardware platform, but the Linux community tries to reuse boot loader code pieces while making boot loaders compatible with multiple SoCs. Despite the variety of SoCs and custom boot loaders, Linux has achieved compatibility with a variety of platforms, continuously decreasing the number of custom boot loaders and taking preference for generic and open solutions such as U-Boot and Redboot [ 20 ], which are the preferred solutions for embedded systems because they minimize hardware dependency by reusing a generic first stage where it is only necessary to adapt a small piece of code for each platform. Currently, Das U-Boot is the most widely used solution, since, like Linux, it is open software supported by a community and is compatible with a variety of ASIC-based SoCs, Single-Board Computers (SBCs) and FPGA/SOCs. Also, it supports development boards with microprocessors like ARM, AVR32, Blackfin, x86, Motorola 68K, AMD Microblaze, MIPS, Altera Nios, Nios2, PowerPC, Super-H, etc., and it is a good starting point for new boot loader developments [26]. Electronics 2024,13, 3731 5 of 19 All Linux boot loaders support file systems in some sub-stage of the process, since the Linux kernel image is size-variable and is frequently updated along the device’s lifetime. In addition, the availability of the file system improves the update capabilities of the system. Das U-Boot follows a standard Linux boot-up process that expects a kernel stored as a regular file in a file system. Thus, Das U-boot supports all modern file systems included in current Linux kernels. 2.3. File Systems in Embedded Linux The Linux user space initialization stage is started when a large file system with the user data and applications is mounted, though sometimes it is more complex since multiple file systems may be mounted across the file system hierarchy. In Linux distributions, the kernel image and the RAM disk, if present, are stored in a file system. In this way, the kernel can be replaced or updated by writing or overwriting these files during the Linux run-time. Moreover, in removable setup mode, the kernel can be easily changed from an external desktop computer, but the file system makes the boot loader code complex since it must search for and read the files from a file system at boot time as has already been mentioned. Thus, the performance of the boot loader is heavily dependent on the ability to manage the file system efficiently, and for this reason, the file system selected for the boot process is of the utmost importance to improve the performance of the Linux boot process [ 24 ]. However, it is not always possible to change the initial file system used by the boot loader. Some SoC manufacturers integrate file system support into the on-chip firmware. This increases the firmware size since two levels of software drivers must be included: storage medium drivers (SD card, eMMC, etc.) and file system drivers. The size limitations of the firmware make it not possible to support complex file systems like ext4, btrfs and others, or use advanced features like journaling, snapshots, compression, etc. Other SoCs, choose to include only the medium access drivers, accessing the storage medium in raw mode, and leaving file system support for a secondary customizable stage. In boot loaders, file systems designed without complex data structures are the best option. Therefore, there are some file systems with a simple layout whose implementation has a low software footprint aimed to be used by Linux in the boot-up process, like Read- Only File System (ROMFS) or Compressed ROM File System (CRAMFS). They are valid for embedded systems, but they have some limitations, such as the size of the file system and the size of individual files. In fact, ROMFS is very limited and can only be used for very small kernels and small initial RAM disks. Unlike, CRAMFS (developed by Linus Torvald) is more advanced, including features like EXIP for executable files, while keeping it simple. However, these types of file systems are not applicable to all kinds of embedded systems because any change in the contents, such as a driver or the kernel, requires a full file system image regeneration. With these types of file systems, an upgrade to the kernel or some boot loader stage requires two complex steps: (1) a full file system image regeneration and (2) a replacement of the old image safely. The second step is critical since any failure makes the system unbootable. Thus, it is very common to find firmware with FAT16/FAT32 support mainly for two reasons: FAT has a simple internal layout despite it being an old design and, due to its ubiquity in most computer systems, facilitates the sharing of data across their devices. As already explained, the removable setup mode is the preferred configuration for general-purpose SBCs and for SoC-based designs in general, with SD cards being the current preferred medium. Most SBC Linux distributions store the kernel in a file system that can be accessed in read/write mode by Linux itself, mounted in the /boot directory. The main reason for this configuration is to make it easy to change or upgrade the OS using a desktop computer, even auto-update it from the running OS. Custom designs such as those implemented in FPGA/SOCs can be fully customized to support different booting strategies, like booting Linux from SD cards in a single boot stage. Electronics 2024,13, 3731 6 of 19 In any scenario, the boot process will benefit from having the kernel and a possible RAM disk image in a file system that is easy to handle from a resource-limited firmware code, for this task, the NanoFS has been chosen due to being specifically designed for that. 3. Nano File System NanoFS is a light file system aimed at being used with reduced software or directly embedded in hardware due to its small footprint. It is designed with simple internal data structures to be handled with low-memory resources and has an optimized internal layout to reduce file lookup and file read algorithms. NanoFS is a good choice for the first boot loader stage, even for the kernel fetch stage, since only read operations are used. The internal structure of this file system facilitates the construction of a low-footprint hardware module that can replace the internal firmware for reading files from a NanoFS. Hence, it is a suitable option for use in IoT devices where minimizing area and resources to implement a hardware boot loader is crucial. At the user level, it is similar to other file systems where the files are organized in a hierarchical structure building a directory tree. Also, at the physical level, it is quite similar to other file systems that use the logical block addressing scheme, which consists of dividing the available space into fixed-size blocks called logical block (l-block), but in the internal data structures, NanoFS is quite different from other file systems like FAT or Extended series. The main design differences are summarized as follows: 1. Small l-block size: 1 byte and 512 bytes. 2. Reduced types of l-blocks named: dir node,data node and metadata node. 3. Decentralized file system data structure to minimize implementation resources. 4. Internal layout structured around forward lists to simplify file system algorithms implementations. The following subsections detail the internal layout of NanoFS that is necessary to understand the simplified algorithms for NanoFS operations, such as file lookup and file reading. 3.1. NanoFS Layout Like other file systems, NanoFS divides the storage device into an array of l-blocks. All l-blocks are referenced by a 32-bit unsigned integer number; thus, the file system is limited to 4G l-blocks. The size of the l-block is set when the file system is created, taking the values shown in Table 1. Valid block size values were chosen to achieve the best performance according to the storage technology used. The relationship between physical block and logical block size directly impacts file system performance; thus, a primary rule for most file systems is to match their sizes or at least to use a multiple number. Table 1. NanoFS valid block sizes. s_Blocksize Block Size File System Size Limit 0 1 byte 4 G bytes 1 512 bytes 2 T bytes 2 1024 bytes 4 T bytes 3 4096 bytes 16 T bytes The size of the l-block also impacts the complexity of the software required to manage the file system. In this sense, NanoFS allows small l-block sizes like 1 byte or 512 bytes, designed mainly to be used in devices with limited resources. The 1-byte size is proposed to be used for on-board ROM memories due to minimize the wasted space by the file system’s internal structures. The second fits with the SD card protocol block size and is intended to optimize the temporal data used in the file system driver for this storage media. To reduce the resources to manage the file system, the NanoFS specification includes a small amount of data structures stored in Little-Endian format: superblock,dir node,data node Electronics 2024,13, 3731 7 of 19 and metadata node. In block 0, the super-block record is located that contains key information to manage the file system. The later l-blocks contain data structures called node with the following characteristics: • Each node is referenced by a unique 32-bit unsigned integer called node number. It corresponds to the l-block where the node starts. • All l-blocks are part of some node. This is required to preserve the file system integrity. • The file system nodes can be of three types: dir node,data node and metadata node. •Dir nodes are intended to compose the file system hierarchy. • Data nodes stores the user data of a file and a header with file system internal data. In this way, the data node header is used to navigate to the next allocated data node for the current file. • The data node is size-variable and consists of single or multiple consecutive l-blocks. It can be extended to consecutive l-blocks to improve the sequential file read/write performance and to reduce the file system fragmentation. •Metadata nodes are optional, reducing the file system weight if they are not included. A NanoFS formatted device is built over two lists of nodes starting at the superblock. Both are forward lists referenced by the node numbers called the data allocated nodes and free nodes. The whole file system is a forward list that can be navigated keeping only a single file system handle, the current node number. Each node always contains a record with a node number referencing the next node in the file system structure. In addition, the dir nodes and data nodes structures contain the records detailed in Tables 2and 3, respectively. Table 2. Records in the dir node data structure. Offset Size Record Description (Bytes) (Bytes) 0 1 d_flags Dir node flags 1 4 d_next_ptr Node of next dir node 5 4 d_data_ptr Node of first child node 9 4 d_meta_ptr Node of first metadata node 13 1 d_fname_len Length in bytes of filename 14 256 f_name Name of file 270 34 f_meta Standard metadata Table 3. Records in the data node data structure. Offset Size Record Description (Bytes) (Bytes) 0 4 d_next_ptr Node of next data node 4 4 d_len Data length 8 d_len d_data Data Figure 2contains an example of a NanoFS formatted device using a 512-byte l-block size. The example has a directory structure that starts in the root directory with one subdirectory and four files (Figure 2a). Additionally, it enumerates the sequence of lblocks along the device highlighting the dir nodes. Starting at superblock (l-block 0), the file system has the two lists referenced by its node numbers:s_alloc_ptr references the list of data allocated nodes (l-block 1) and s_free_ptr references the free nodes list (l-block 13). The file system hierarchy begins at the root dir node (l-block 1) and is a list of dir nodes linked by two records: d_next_ptr and d_data_ptr. The d_next_ptr record always addresses the next dir node in the current directory until the last dir node is reached; in the last case, the value is 0 (end mark). The d_data_ptr record can point to another dir node or to a data node. To distinguish it, each dir node is flagged in the d_flags record as a file or directory. When a dir node is a file, d_data_ptr addresses the first data node of the file. Instead, whether it is flagged as Electronics 2024,13, 3731 8 of 19 a directory, it represents a subdirectory and d_data_ptr points to the dir node where the subdirectory starts. The files are stored in data nodes that contains a small header followed by the file data, as is detailed in Table 3. A file consists of a single or multiple data nodes organized in a forward list and a data node can be extended to multiple consecutive l-blocks. f2 f3 f4df1r Superblock s_alloc_ptr dDir-node flagged as dir Data-node 0 1 d_next_ptr node record d_data_ptr node record fDir-node flagged as file rRoot dir-node s_free_ptr 32 r f1 d1 f3 f4 f2 Directory structure 7 Node 5 (512Bytes) d_next_ptr d_len data 504 4Bytes 4Bytes 504Bytes 0 52 Node 7 (512 Bytes) 0 2032 l-block 9 504Bytes 512Bytes 512Bytes 12Bytes 4 5 6 7 8 9 10 11 12 13 14 15 16 d_next_ptr d_len data d_next_ptr d_len data l-block 11l-block 10 l-block 12 500Bytes 4Bytes 4Bytes Node 9 (2048 Bytes) l-block 5 l-block 7 Unused area l-block boundary 4Bytes 4Bytes 52Bytes 452Bytes (a) (b) Figure 2. NanoFS layout example: (a) directory structure and (b) nodes detail. Figure 2a has an example of two files with allocated data: f1 and f2. The d_data_ptr records point to node 9 (l-block 9) and node 5 (l-block 5), respectively. Figure 2b details the nodes for both files, where f2 is a fragmented file in two nodes (5 and 7) and each node fits with a single l-block. Instead, f1 is an unfragmented file with a single node (9) that is expanded through four consecutive l-blocks (from 9 to 12). For large files, read/write operations can be sped up because data are allocated in consecutive physical blocks, especially for storage technologies with accelerated sequential access modes support, such as CMD8 protocol command on SD cards. NanoFS manages the free nodes in another forward list of data nodes referenced from the superblock. In Figure 2, the free nodes start at node 13 (l-block 13), referenced by the s_free_ptr record of the superblock, and it has only one expanded data node (l-blocks 13 to 16). Finally, the intended purpose of the metadata nodes list is to extend the file system with custom features if a specific application requires them. Consequently, they are not mandatory and are not covered in this work. Electronics 2024,13, 3731 9 of 19 3.2. NanoFS Implementations The complexity and resources required for the implementation of file system operations depend on the internal layout, internal data structures, and the storage media used. The relationship between the file system l-block size not only affects the performance, but there is also a direct relationship between the resources required for the read/write algorithms. There are two recommended rules that are generally accepted to achieve optimal behavior: (1) set the l-block size to a multiple of the physical block size, (2) set the start offset of the file system to be aligned with a physical block, especially for devices with a large physical block size, such as Flash memory. Referring to SD cards, they work with a serial bit stream protocol in 1-bit or 4-bit transference mode. The SD protocol also includes a 1-bit SPI mode, which is a reduced subset of the protocol aimed at supporting limited host devices. In both modes, the protocol assumes a 512-byte block size for data transference; therefore, the SD optimal l-block size for a partition formatted with NanoFS is this size. When matching the l-block size, the procedures to manage NanoFS are optimal, with the result of a simplified algorithm that is able to run with very-low-memory resources. In this way, Algorithms 1and 2depict a possible implementation for file lookup and file read procedures. The file lookup procedure can be implemented using a single handle that is the current node number (a 32-bit unsigned integer). It can be seen in Algorithm 1, which describes a non-recursive file lookup starting at the root directory. The file lookup ends once the file is located; after that, the d_data_ptr record has the dir node number of the file, which will be used later as a handle to read the file data in the read procedure. Algorithm 1 Lookup file procedure procedure LOOKUP(f ile_name) handle ←root_dir_node.d_data_ptr while handle =0do d_f lags ←get_bytes(handle,1) if (d_f lags ∧0x07) = 0x01 then ▷dir_node is a file ◁ if match(f ile_name)then break end if else ▷navigate to next dir node ◁ handle ←get_bytes(handle,4) end if end while return handle end procedure Algorithm 2 Read file procedure procedure READ_FILE(dir_node) handle ←dir_node.d_data_ptr while handle =0do d_next_ptr ←get_bytes(handle,4) d_len ←get_bytes(handle,4) read_data(handle,d_len) handle ←d_next_ptr end while end procedure Hence, the Algorithm 2depicts the read procedure taking the previous handle (d_data_ptr) and needs two additional 32-bit numbers to read the file content. Both procedures call the Electronics 2024,13, 3731 16 of 19 Table 7. Linux kernel fetch time (initial configuration). FPGA Processor System Clk (MHz) SD Clk (MHz) DDR Clk (MHz) Fetch Time (s) XC7A35T OpenRisc 83 20.75 333.33 3.87 MicroBlaze 83 20.75 333.33 5.01 XC7A100T OpenRisc 83 20.75 333.33 3.88 MicroBlaze 83 20.75 333.33 5.00 XC7K325T OpenRisc 83 20.75 333.33 3.86 Microblaze 83 20.75 333.33 4.96 Table 8. Linux kernel fetch time (optimal configuration). FPGA Processor System Clk (MHz) SD Clk (MHz) DDR Clk (MHz) Fetch Time (s) XC7A35T OpenRisc 83 20.75 333.33 3.87 MicroBlaze 83 20.75 333.33 5.01 XC7A100T OpenRisc 100 25 200 3.22 MicroBlaze 100 25 200 4.17 XC7K325T OpenRISC 200 25 800 2.60 Microblaze 200 25 800 3.70 The complete Boot time is the time elapsed until the Linux kernel starts the init process (process 0). It has been measured for the three platforms and the results are shown in Table 9. This time is the sum of Fetch time and Kernel boot and is measured by using a logic analyzer that monitors the GPIO pin that is asserted when the init process starts. Table 9. Linux kernel boot time. FPGA Processor System Clk (MHz) Fetch Time (s) Kernel Boot (s) Boot Time (s) XC7A35T OpenRISC 83 3.9 0.06 3.96 MicroBlaze 83 5.0 1.1 6.10 XC7A100T OpenRISC 100 3.2 0.05 3.25 MicroBlaze 100 4.2 1.0 5.20 XC7K325T OpenRISC 200 2.6 0.04 2.64 MicroBlaze 200 3.7 0.8 4.50 Most factory solutions for FPGA/SOCs do not support booting from an SD card, since they are intended to boot from an internal Block RAM (BRAM) or using Joint Test Action Group (JTAG) to transfer the kernel. Thus, the closest to a standard solution is PetaLinux [ 34 ] from AMD, which is used as a reference to compare with NanoBoot. Petalinux has been designed to boot a Linux system on a Microblaze processor from an SPI Flash memory. Petalinux is a non-free system, but it uses a conventional boot loader based on U-Boot which is preprogrammed as internal firmware (FPGA BRAM) that acts as a preloader. The Petalinux boot process has multiple stages, starting at the BRAM preloader, which obtains the next stage from an off-chip Flash memory. A Microblaze system booted using Petalinux with the kernel stored in the on-board SPI Flash memory has been deployed on the three prototype boards. The Petalinux preloader is not able to use any file system; therefore, the kernel is stored in raw mode in the offchip SPI Flash. The Petalinux kernel used is a Linux 5.15.36 with 10.4 MB size, similar to Electronics 2024,13, 3731 17 of 19 the one used in the OpenRISC and Microblaze SoCs are used as examples in this paper. Table 10 compares boot time with the measures taken using the same GPIO-based method described above, consisting of asserting a GPIO when the kernel launches the init process. The OpenRISC and Microblaze rows correspond to results using the proposed hardware boot loader using NanoFS, while the Petalinux rows correspond to the factory solution using Petalinux. The results obtained in Table 10 clearly show that the use of a full hardware boot loader with a file system does not have a negative impact on the OS boot time compared to the standard Petalinux AMD solution. Moreover, the boot times of the hardware solutions are much better with the added benefits of booting from a file system. Table 10. Power-on time. SoC Boot Time (s) Arty—OpenRISC 4.0 Arty—Microblaze 6.1 Arty—Petalinux 42.6 Nexys4—OpenRISC 3.3 Nexys4—MicroBlaze 5.2 Nexys4—Petalinux 36.4 Genesys2—OpenRISC 2.6 Genesys2—Microblaze 4.5 Genesys2—Petalinux 51.2 6. Conclusions This paper introduces NanoBoot, a novel boot loader for embedded devices that uses the NanoFS light file system on removable SD card media. The simplicity of NanoFS makes it possible to boot a Linux system using a full-hardware boot loader in FPGA/SOCs and offers a convenient and easy procedure for system OS updates. Full-hardware boot-loading capabilities are demonstrated with OpenRISC and Microblaze FPGA/SOCs. The hardware resources needed by the boot loader are low (about 7% of the whole system) and the boot time is greatly reduced compared to the standard solution using Petalinux on SPI Flash. Author Contributions: Conceptualization, P.R.-d.-C., G.C.-Q. and J.J.; methodology, P.R.-d.-C., G.C.-Q. and J.J.; software, P.R.-d.-C. and G.C.-Q.; validation, P.R.-d.-C., G.C.-Q., J.J., M.J.B., J.V.-C., D.G. and E.O.; formal analysis, P.R.-d.-C. and G.C.-Q.; investigation, P.R.-d.-C., G.C.-Q. and J.J.; resources, M.J.B., J.V.-C., D.G. and E.O.; data curation, P.R.-d.-C. and G.C.-Q.; writing—original draft preparation, P.R.-d.-C., G.C.-Q. and J.J.; writing—review and editing, P.R.-d.-C., G.C.-Q., J.J., M.J.B., J.V.-C., D.G. and E.O.; visualization, P.R.-d.-C., G.C.-Q. and J.J.; supervision, P.R.-d.-C., J.J. and M.J.B.; project administration, J.J., P.R.-d.-C. and M.J.B. All authors have read and agreed to the published version of the manuscript. Funding: This work has been funded by the Ministry for Digital Transformation and Public Function through grant USECHIP (TSI-069100-2023-001) of PERTE Chip Chair program, funded by European Union—Next Generation EU. Data Availability Statement: The data presented in this study are openly available in [NanoBoot] [https://github.com/germancq/NanoBoot] (accessed on 20 July 2024). Conflicts of Interest: The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results. Electronics 2024,13, 3731 18 of 19 Abbreviations IoT Internet of Things SoC System-on-Chip NVM Non-Volatile Memory ROM Read-Only Memory MCUs Micro-Controller Units OS Operating System FAT File Allocation Table FLT Flash Translation Layer FPGA Field-Programmable Gate Array SD Secure Digital RISC Reduced Instruction Set Computer MMU Memory Management Unit IP Core Intellectual Property Core AXI4 Advanced eXtensible Interface 4 ROMFS Read-Only File System CRAMFS Compressed ROM File System l-block logical block HDL Hardware Description Language MBR Master Boot Record FSM Finite State Machine GPIO General Purpose InputOutput BRAM Block RAM JTAG Joint Test Action Group References 1. Sloss, A.; Symes, D.; Wright, C. ARM System Developer’s Guide: Designing and Optimizing System Software; Elsevier Science: Amsterdam, The Netherlands, 2004. 2. Lewandowski, M.; Orczyk, T.; Porwik, P. Dedicated AVR bootloader for performance improvement of prototyping process. In Proceedings of the 2017 MIXDES—24th International Conference Mixed Design of Integrated Circuits and Systems, Bydgoszcz, Poland, 22–24 June 2017; pp. 553–557. 3. Bogdan, D.; Bogdan, R.; Popa, M. Design and implementation of a bootloader in the context of intelligent vehicle systems. In Proceedings of the 2017 IEEE Conference on Technologies for Sustainability (SusTech), Phoenix, AZ, USA, 12–14 November 2017; pp. 1–5. 4. Kang, Y.; Chen, J.; Li, B. Generic Bootloader Architecture Based on Automatic Update Mechanism. In Proceedings of the 2018 IEEE 3rd International Conference on Signal and Image Processing (ICSIP), Shenzhen, China, 13–15 July 2018; pp. 586–590. 5. Nuratch, S. A serial Bootloader with IDE extension tools design and implementation technique based on rapid embedded firmware development for developers. In Proceedings of the 2017 12th IEEE Conference on Industrial Electronics and Applications (ICIEA), Siem Reap, Cambodia, 18–20 June 2017; pp. 1865–1869. 6. Sha, C.; Lin, Z.Y. Design Optimization and Implementation of Bootloader in Embedded System Development. In Proceedings of the 2015 International Conference on Computer Science and Applications (CSA), Wuhan, China, 20–22 November 2015; pp. 151–156. 7. Intel, C. Understanding the Flash Translation Layer (FTL) Specification. 1998. Available online: http://dooroos.org/download_ documents/FTL_INTEL.pdf (accessed on 10 October 2023). 8. Boukhobza, J.; Olivier, P. Chapter 7—Flash Translation Layer. In Flash Memory Integration; Elsevier: Amsterdam, The Netherlands, 2017; pp. 129–147. [CrossRef] 9. de Clavijo, P.R.; Ostua, E.; Juan, J.; Bellido, M.J.; Viejo, J.; Guerrero, D. NanoFS: A hardware-oriented file system. Electron. Lett. 2013,49, 1216–1218. [CrossRef] 10. Wu, C.H.; Kuo, T.W. An adaptive two-level management for the Flash translation layer in embedded systems. In Proceedings of the 2006 IEEE/ACM International Conference on Computer Aided Design, San Jose, CA, USA, 5–9 November 2006; pp. 601–606. 11. Liu, Y.; Zhang, Z.; Xu, J.; Xie, G.; Li, R. Coded worn block mechanism to reduce garbage collection in SSD. J. Syst. Archit. 2022, 126, 102487. [CrossRef] 12. SD Specifications Part 1 Physical Layer Simplified Specification Version 5.0; Technical Report; Technical Committee SD Card Association: San Ramon, CA, USA, 2016. 13. RISC-V International. Available online: https://riscv.org/ (accessed on 20 October 2023). 14. Intel Corp. Nios II Processor Reference Guide, NII-PRG—2020.04.24; Intel Corp.: Santa Clara, CA, USA, 2020. 15. Xilinx; IARR. Microblaze Processor Reference Guide; Xilinx: San Jose, CA, USA, 2006. Electronics 2024,13, 3731 19 of 19 16. OpenRISC Community. Available online: https://openrisc.io (accessed on 8 August 2023). 17. OpenCores. Available online: http://opencores.org (accessed on 8 August 2023). 18. Silicore, T.M. WISHBONE System-on-Chip (SoC) Interconnection Architecture for Portable IP Cores; Revision B3; Silicore TM: Shaoxing, China, 2002. 19. Arm Limited. AMBA AXI and ACE Protocol Specification; Arm Limited: Cambridge, UK, 2011. 20. Yaghmour, K.; Masters, J.; Ben, G. Building Embedded Linux Systems, 2nd ed.; O’Reilly & Associates, Inc.: Sebastopol, CA, USA, 2008. 21. PramodKumar Singh, P.S.K. Startup Time Optimization Techniques for Embedded Linux. Int. J. Sci. Eng. Res. 2016,7, 742–745. 22. Gu, C. Power On and Bootloader. In Building Embedded Systems: Programmable Hardware; Apress: Berkeley CA, USA, 2016; pp. 5–25. 23. Lee, D.; Won, Y. Booting Linux faster. In Proceedings of the 2012 3rd IEEE International Conference on Network Infrastructure and Digital Content, Beijing, China, 21–23 September 2012; pp. 665–668. [CrossRef] 24. Ho Chung, K.; Sil Choi, M.; Seon Ahn, K. A Study on the Packaging for Fast Boot-up Time in the Embedded Linux. In Proceedings of the 13th IEEE International Conference on Embedded and Real-Time Computing Systems and Applications (RTCSA 2007), Daegu, Republic of Korea, 21–24 August 2007; pp. 89–94. [CrossRef] 25. Park, C.; Kim, K.; Jang, Y.; Hyun, K. Linux bootup time reduction for digital still camera. In Proceedings of the Linux Symposium, Ottawa, ON, Canada, 19–22 July 2006; p. 231. 26. Denk, W. Das U-Boot—The Universal Boot Loader, rev r1.30—30 Mar 2020. 2020. Available online: https://github.com/u-boot/ u-boot (accessed on 20 July 2023). 27. Rath, N. FUSE—Filesystem in Userspace. Available online: https://github.com/libfuse/libfuse (accessed on 6 July 2023). 28. Sources for NanoBoot. Available online: https://github.com/germancq/NanoBoot-systemverilog (accessed on 20 July 2024). 29. de Clavijo, P.R.; Ostua, E.; Bellido, M.J.; Juan, J.; Viejo, J.; Guerrero, D. Minimalistic SDHC-SPI hardware reader module for boot loader applications. Microelectron. J. 2017,67, 32–37. [CrossRef] 30. Digilent, Inc. Nexys4 DDR FPGA Board Reference Manual; Digilent, Inc.: Pullman, WA, USA, 2016. 31. Digilent, Inc. Arty TM FPGA Board Reference Manual, Rev. C; Digilent, Inc.: Pullman, WA, USA, 2017. 32. Xilinx Inc. 7 Series FPGAs Data Sheet: Overview. DS180 (v2.6) Product Specification; Xilinx Inc.: San Jose, CA, USA, 2018. 33. Digilent, Inc. Genesys 2 FPGA Board Reference Manual, Rev. F; Digilent, Inc.: Pullman, WA, USA, 2017. 34. Xilinx Inc. PetaLinux Tools DocumentationReference Guide, UG1144 v2018.2; Xilinx Inc.: San Jose, CA, USA, 2018. Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.