Skip to main content
Visitor II
December 20, 2017
Question

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

  • December 20, 2017
  • 3 replies
  • 4559 views
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
    This topic has been closed for replies.

    3 replies

    Graduate II
    December 20, 2017
    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.

    digital BAuthor
    Visitor II
    December 20, 2017
    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?

    Super User
    December 20, 2017
    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.

    Super User
    December 20, 2017
    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!

    digital BAuthor
    Visitor II
    December 20, 2017
    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.

    Super User
    December 20, 2017
    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.

    digital BAuthor
    Visitor II
    December 20, 2017
    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?

    Super User
    December 21, 2017
    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!

    digital BAuthor
    Visitor II
    December 21, 2017
    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 ...

    :(