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 20:01

You write a .BIN file to the faux drive, and the ST-LINK/mbed firmware writes it into the STM32F429 FLASH (0x08000000 ?). It uses the SWD protocol.

The files never really exist in a meaningful or accessible manner.

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 20, 2017 at 20:28

Thanks, Clive.

I know about .bin files.

What I am asking about is how can I access a file from the code already running on the STM32F429.

For example, I put the file to the faux drive and the STM32F429 code immediately finds it and does something with it.

Any idea where the files are in the flash and in what format?

Posted on December 20, 2017 at 20:37

That's not the way it works.

It's only pretending to be a drive - hence, '

https://en.oxforddictionaries.com/definition/faux

'.

It's just a way to get firmware loaded into the target without needing an app on the host - like the ST-Link utility.

Posted on December 20, 2017 at 21:42

Well, I just tried googling, 'how does the mbed loader work' and got to this:

https://os.mbed.com/handbook/How-mbed-works

 

So it seems that you can (in theory, at least) access the 'drive' from the target:

How the LocalFileSystem works

https://os.mbed.com/handbook/How-mbed-works#how-the-localfilesystem-works

Because we have a USB disk, we also thought it'd be really useful to let you read and write files to it from the target microcontroller. To do this, the mbed Interface acts like a host debugger and listens out for filesystem 'semihosting' requests via JTAG.

So there you go!

Posted on December 20, 2017 at 20:46

But it does store the file somewhere.

And it is not STM32F103 because it does not have enough memory - it is most likely STM32F429 as it has 2MB flash.

Or is there some other memory on board where it stores 2MB of data?

Posted on December 20, 2017 at 21:24

No, I don't believe it has to store it anywhere. Think of it as a tunnel, where the data just gets written through to the final destination. As Windows, or whatever, writes the blocks of data they go directly into F429 memory via the debug interface and loader code placed in RAM. The access speed is throttled by the responsiveness of the USB MSC implementation, and the host OS sends data in multiples of 512 bytes.

The F429 doesn't recognize the files, or look for them. The F103 pretends to be a MSC device with an emulation of the FAT file system sufficient to fool the host system.

If you create a 2MB binary, and write it to the drive, that 2MB blob will end up in the STM32F429 memory, ie 0x08000000..0x081FFFFF

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 20, 2017 at 21:33

I can read the files back from Windows - so they have to be stored somewhere on the DISC1 board.

They do not go directly to the flash part where the current STM32F429 code is running. I confirmed that - the code runs normally while the files are written, read, deleted to/from the STLink USB drive.

They likely go to the 'unused' part of the STM32F429 flash..

The question is - where exactly?

I suppose STLink firmware in STM32F103 has a way to know up to where is the running code. Not sure what happens when the file is full 2MB ...

Or maybe the files are written in a stack-like fashion, top-down ...

Posted on December 20, 2017 at 22:00

Thanks Andrew.

I suppose then that using 'semihosting' is the way to do it.

I've never used semihosting from target code - are there any examples for STM32F429?

That is, using STLink firmware (not mbed).

More precisely, I mean examples for using semihosting to access the STLink firmware filesystem from the target.

Posted on December 20, 2017 at 22:21

I've never done it, either - so you're on your own now, I'm afraid ...

I have been told that Semihosting is possible with ST-Link.

AIUI, the '

STLink firmware' implements mbed - which is how you get the 'drive' appearing on the PC.