cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 - FileX and MSC - Windows read wrong data

Dams
Associate III

Hi, 

I'm on a applicaiton involving USBX MSC and FileX. 
The final memory for the application is a NOR flash so I also use LevelX.

Acutally, I'm working on a nucleo-U575ZI-Q without NOR flash so I use NOR Simulator on LevelX.

My problem is that a file created with FileX is detected by windows, have the right number of bytes but data are wrong.

My program do this:

1) FileX format the device
2) FileX create the file STM32.TXT and put the data "This is FileX working on STM32". I can see this data on the RAM

3) FileX close and open the file STM32.TXT and I can read the text

4) FileX close the media.

5) USBX open the media and on Windows I see the file STM32.TXT but data are not correct. It's like if this data comes from another part on my RAM.

Dams_0-1760544703605.png

When the device is connected to a computer, I can create new file, write on it then unplug / plug USB and the new file is still here. I can also edit STM32.TXT.

Has somebody an idea about why FileX can read right data but windows doesn't read right data even if the device is mounted.

Thanks for help !

 

 

 

 

19 REPLIES 19

Hi Dmitry, 

The program works with 512 and 1024 bits but my target has a sector of 4096 bits. So I need to validate the program on my RAM with sector of 4096 bits before moving to the NOR chip.

 

Regards,

Dams

 

Hi Dams,

 

I understand it but I suppose than large sector sizes for emulator may be unsupported.

 

With best regards,

Dmitry

Hi Dmitry, 

It is really strange because with 4096 bits, LevelX is able to create file, read file and close it, as well as USBX il able to present an empty mass storage to windows and windows can format the drive, create file,...
It's just not working when I use both of them with sector size > 1024 bits..

Regards, 

Dams

 

Hi Dams,

 

once again, please check that you have excluded simultaneous access to media when you use them together.

 

With best regards,

Dmitry

Hi Dmitry, 

You can see on my main.c that FileX is called once, juste before USBX.
Regards,

Hello Dams,

 

so have I understood right that if you do not do this call USBX works then fine but if you do this call it does not work then?

 

With best regards,

Dmitry

Dams
Associate III

Hi Dmitry, 

I'm going to change my glue to stay with sector of 512 bits with FileX and USBX

Thanks for your help.

Regards, 

Dams

 

Hi Dams,

 

if your target device has a physical sector size of 4096 bytes that will not work. And FileX will not help anyway because to access NOR flash you will need to use LevelX. FileX is just on top of LevelX in this case so it cannot help solving problems on LevelX level.

 

With best regards,

Dmitry 

Hello Dams,

I am trying to do same example as yours.
I am just trying to do with internal flash that's why i use custom driver instead of simulator drive.
Can you please share levelx nor driver write, read and erase functions.

Thank you...

Hi Domero,

I added my "lx_stm32_nor_simulator_driver.c" file, but I don't think it's very useful.
Just a tip for your project: be careful with the sector sizes of FileX (U8) and some drivers (sometimes U32).
If you want somthing close to the hardware, you can take a look of files generated by using octo SPI flash (even if you don't have it, just as exemple). Here you can see functions to wait end of operation (not present in simulator)..

Good luck.

Regards,

Dams