Skip to content
4 changes: 3 additions & 1 deletion common/inc/fx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ extern "C" {
#define AZURE_RTOS_FILEX
#define FILEX_MAJOR_VERSION 6
#define FILEX_MINOR_VERSION 4
#define FILEX_PATCH_VERSION 1
#define FILEX_PATCH_VERSION 2
#define FILEX_BUILD_VERSION 202503
#define FILEX_HOTFIX_VERSION ''

/* Define the following symbols for backward compatibility */
#define EL_PRODUCT_FILEX
Expand Down
29 changes: 18 additions & 11 deletions common/src/fx_media_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,17 +443,24 @@ UINT sectors_per_fat, f, s;
_fx_utility_memory_set(&byte_ptr[j + i], ' ', (11 - i));
#endif /* FX_DISABLE_FORCE_MEMORY_OPERATION */


/* Set bootrecord signature. */
#ifdef FX_FORCE_512_BYTE_BOOT_SECTOR

/* Set bootrecord signature. */
byte_ptr[510] = 0x55;
byte_ptr[511] = 0xAA;
/* Put the boot signature in the standard position. */
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;
#else

/* Set bootrecord signature. */
byte_ptr[bytes_per_sector - 2] = 0x55;
byte_ptr[bytes_per_sector - 1] = 0xAA;
if (bytes_per_sector < 512)
{
/* Put the boot signature at the end of the sector. */
byte_ptr[bytes_per_sector - 2] = FX_SIG_BYTE_1;
byte_ptr[bytes_per_sector - 1] = FX_SIG_BYTE_2;
}
else
{
/* Put the boot signature in the standard position. */
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;
}
#endif

/* Select the boot record write command. */
Expand Down Expand Up @@ -510,8 +517,8 @@ UINT sectors_per_fat, f, s;
byte_ptr[487] = 0x61;

/* Build the final signature word, this too is used to help verify that this is a FSINFO sector. */
byte_ptr[508] = 0x55;
byte_ptr[509] = 0xAA;
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;

/* Setup the total available clusters on the media. We need to subtract 1 for the FAT32 root directory. */
_fx_utility_32_unsigned_write(&byte_ptr[488], (total_clusters - 1));
Expand Down
9 changes: 9 additions & 0 deletions ports/cortex_m33/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target_sources(${PROJECT_NAME} PRIVATE
# {{BEGIN_TARGET_SOURCES}}

# {{END_TARGET_SOURCES}}
)

target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)
23 changes: 23 additions & 0 deletions ports/cortex_m33/gnu/inc/fx_port.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Port Specific */
/** */
/**************************************************************************/
/**************************************************************************/

/* Include the generic version of fx_port.h. */
#include "../../../generic/inc/fx_port.h"
47 changes: 36 additions & 11 deletions samples/demo_filex.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2025 Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/


/* This is a small demo of the high-performance FileX FAT file system. It includes setup for
a small 34KB RAM disk and a loop that writes and reads a small file. */
#include "fx_api.h"
Expand Down Expand Up @@ -29,14 +41,16 @@ void thread_0_entry(ULONG thread_input);


/* Define FileX global data structures. */

#define TOTAL_SECTORS 256
#define SECTOR_SIZE 512
FX_MEDIA ram_disk;
FX_FILE my_file;


#ifndef FX_STANDALONE_ENABLE
CHAR *ram_disk_memory;
#else
unsigned char ram_disk_memory[256*512];
unsigned char ram_disk_memory[TOTAL_SECTORS*SECTOR_SIZE];
#endif

/* Define ThreadX global data structures. */
Expand Down Expand Up @@ -102,8 +116,12 @@ CHAR local_buffer[30];


/* Format the RAM disk - the memory for the RAM disk was setup in
tx_application_define above. */
fx_media_format(&ram_disk,
tx_application_define above.

Important Note: The user must ensure there is enough RAM for the format
specified. Otherwise, memory corruption can occur.
*/
status = fx_media_format(&ram_disk,
_fx_ram_driver, // Driver entry
ram_disk_memory, // RAM disk memory pointer
media_memory, // Media buffer pointer
Expand All @@ -112,27 +130,34 @@ CHAR local_buffer[30];
1, // Number of FATs
32, // Directory Entries
0, // Hidden sectors
256, // Total sectors
512, // Sector size
TOTAL_SECTORS, // Total sectors
SECTOR_SIZE, // Sector size
8, // Sectors per cluster
1, // Heads
1); // Sectors per track

/* Determine if the RAM disk format was successful. */
if (status != FX_SUCCESS)
{
/* Error formatting the RAM disk. */
printf("HTTPS RAM disk format failed, error: %x\n", status);
return;
}

/* Loop to repeat the demo over and over! */
do
{

/* Open the RAM disk. */
status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, media_memory, sizeof(media_memory));

/* Check the media open status. */
/* Determine if the RAM disk open was successful. */
if (status != FX_SUCCESS)
{

/* Error, break the loop! */
break;
/* Error opening the RAM disk. */
printf("RAM disk open failed, error: %x\n", status);
return;
}


#ifdef FX_ENABLE_FAULT_TOLERANT
status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_memory, sizeof(fault_tolerant_memory));
Expand Down