cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429I-DISC1 How to read files written through STLink USB port?

digital B
Associate II
Posted on December 20, 2017 at 19:06

When the DISC1 board is connect to a Windows PC, it is seen as MSC USB drive of 2MB capacity, labeled 'DIS_F429ZI'.

I can write files to it and they are readable from Windows.

I assume the files are stored in the STM32F429 internal flash since the capacity matches.

Is there a way to access these files from the STM32F429I microcontroller?

I know I can access the flash memory - but how can I locate the files in it?

I suppose the STM32F103 microcontroller that runs STLink is handling the file system for this, hence the files 'disappear' after power cycle (unplugging STLink cable). However, I guess it is still writing the files to some predetermined location in the flash.

I could not find any examples for this or maybe I'm searching for wrong terms ...

Does anyone have any info about this?

#dis_f429zi #stm32f429i-disc1 #stm32-stlink
18 REPLIES 18
Posted on December 20, 2017 at 22:53

OK, thanks once more!

I'll look it up.

Interestingly, I've just wrote 2036KB long file (in addition to 8KB allocated for files always there) to the STLink drive and the target code (28KB) kept running ... even after target reset ...

The big file does read back correctly, so it is stored somewhere on board ... but where?!

Update: The file of 2040KB can be written too but does not read back correctly (reads as all zeros). Target code still runs correctly.

digital B
Associate II
Posted on December 21, 2017 at 00:31

So I wrote a 512KB text file with a distinct pattern to the STLink USB drive and read STM32F429 flash memory (0x08000000-0x08200000) using the STM32 ST-LINK utility and guess what - the file is not there!

This means that the files are really not stored anywhere on the board as there is not enough space anywhere else than in the STM32F429 flash.

The drive might be faux after all ...

The

https://os.mbed.com/handbook/LocalFileSystem

in a warning about external flash hints that the files are stored locally though ...

Maybe STLink firmware changed that ... but where does it store the files?! Are they somewhere off-board in a buffer along the USB-PC-Windows path?

Posted on December 21, 2017 at 01:07

The files would be stored in the 'mbed interface' - ST-Link, in this case - certainly not on the target device!

That's why the Target device has to use Semihosting to access them!

Posted on December 21, 2017 at 01:22

You can't mean the STM32F103 that runs the STLink firmware on the STM32F429I-DISC1 board - it does not have the memory size for it.

By 'on-board' I meant 'on the STM32F429I-DISC1 board' - there is no device on the board except the STM32F429 that has the 2MB storage space (the 64Mbit SDRAM chip is connected to STM32F429 and would need it to be accessible - the target code I'm running is using the GPIO ports SDRAM is connected to so it cannot work that way).

Wherever the files are actually stored, you are correct that target needs semihosting to access them.

I'm trying to find some code for LocalFileSystem/semihosting support on STM32 and, so far, have found only posts that say it does not work with STM32 ...

:(

Posted on December 21, 2017 at 02:26

More probably cached by the host, the real test would be to Right Click Eject, and then remount.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 21, 2017 at 09:10

Another test could be to disconnect the Discovery board's ST-Link from its Target chip, and connect it to a different chip ...

Posted on December 21, 2017 at 10:12

Good idea, Clive - after ejecting it the drive remounts without my files.

So this confirms that files are cached somewhere off-board.

That might explain why people are saying that LocalFileSystem does not work with STLink ...

I will give semihosting and LocalFileSystem  one more look, just in case.

Posted on December 21, 2017 at 10:23

That 'How mbed works' page definitely shows storage attached to the 'mbed interface':

https://os.mbed.com/media/uploads/simon/mbed-internals.jpg

and says that's what it uses for theLocalFileSystem

So, as the ST-Link has no such storage, it would seem fair to conclude that the ST-Link can't do the

LocalFileSystem.

However, the ST-Link should still be able to support Semihosting to access files on the Host ...

Posted on December 21, 2017 at 17:00

True.

I wish I could find some concrete information about semihosting file access over STLink.

The most I can get to work is printf.