Why available size of flash(obtained using fx_media_space_available) remains same irrespective of hidden sectors argument in fx_media_format?

Vinay 40 Reputation points
2024-04-08T06:03:08.73+00:00

I am using NOR flash with 32Mb size and 4KB sector size.

When flash is formatted with 100 hidden sectors, available space obtained from fx_media_space_available is 4177920.

When flash is formatted with 300 hidden sectors(or 0 hidden sectors), available space is 4177920.

Why is this so?

What is the purpose of specifying hidden sectors if formatting considers whole flash?

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
331 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sakshi Kokardekar 200 Reputation points MVP
    2024-04-08T15:19:38.28+00:00

    Here's a general approach you can try for the same:

    Direct Flash Access: Since you can't rely on FileX to handle partitioning or excluding certain flash regions, you'll need to manage this manually in your application. Use the direct flash access APIs provided by your hardware abstraction layer or flash driver to read from and write to specific flash memory addresses.

    Partitioning Logic: Implement logic in your application to determine which flash memory addresses belong to the file system partition and which belong to the partition for storing raw binaries. You'll need to define the boundaries of these partitions based on the total size of the flash memory and any specific requirements or constraints.

    File System Management: Within the file system partition, you can use FileX APIs as usual to create directories, manage files, and perform file system operations.

    Raw Binary Storage: For the partition dedicated to raw binaries, implement custom logic to manage storage and access. You'll need to define your own data structures and algorithms for storing and retrieving raw binary data from this partition.

    Integration: Integrate your partitioning logic with your application's overall architecture. Ensure that other components of your system are aware of and respect the boundaries of the file system and raw binary partitions.

    Testing and Validation: Thoroughly test your implementation to ensure that it correctly handles partitioning, file system operations, and raw binary storage. Validate that data integrity is maintained and that there are no unexpected interactions between the partitions.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sakshi Kokardekar 200 Reputation points MVP
    2024-04-08T06:29:59.24+00:00

    Hidden sectors in NOR could be used to hold metadata, details of the file system, or other internal data structures that are required for the flash memory to function. Also, these hidden sectors of the flash memory are usually not directly accessible by the user. They are kept for the system purposes.

     

    A certain amount of hidden sectors are allocated by the file system for internal usage when flash memory is formatted; nevertheless, this has no effect on the user's reported available space. Usable storage space, which does not include hidden sectors, is reflected in the available space that functions such as fx_media_space_available report to the user.

     

    In your case, as you are shown with the same amount of available space (i.e 4177920) regardless of whether you format the flash memory with 100, 300, or let’s say you take it even 50 hidden sectors, it implies that the accessible storage capacity to you is not being directly impacted by the concealed sectors. The purpose of specifying hidden sectors is primarily for system use and management by the file system.

     

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.