Skip to main content
Visitor II
March 24, 2021
Question

I have an algorithm in C wich read and write a .txt file. I know that i could do this by serial port but need of it on the board for a stande alone application so i want to know if i just drag the file i the .txt file into the mcu like for programing

  • March 24, 2021
  • 3 replies
  • 1755 views

I have to know if the file will stay into the mcu memory in this way and if the c program will work or if this idea il wrong and i cant do in this way.

    This topic has been closed for replies.

    3 replies

    Graduate II
    March 24, 2021

    Hard to say I'm clear on the detail here. Depending on what exactly you're trying to achieve this could get fairly complicated.

    Dropping files, probably want to use a USB MSC or MTP device, with some storage and FatFs. Do you have external flash, eMMC or microSD in your implementation.

    FatFs provides f_open, f_read equivalents to fopen, fread on typical C w/OS platforms.

    Serial you could use a terminal, or X-Modem to transfer a configuration file.

    With Host side application you could hide a lot of the detail.

    Super User
    March 24, 2021

    "drag the file i the .txt file into the mcu like for programing one"

    When you program a microcontroller by drag & drop like that, you are actually "dropping" onto the programmer/debugger - not the Target microcontroller itself.

    The programmer/debugger then takes the "dropped" file, and programs it into the Target microcontroller via the SWD (or JTAG) interface.

    So the Target microcontroller never actually "sees" the dropped file.

    "the file will stay into the mcu memory in this way"

    The file itself is never in the Target MCU's memory.

    If you are doing this on a Discovery or Nucleo board - where the programmer/debugger will stay attached - there is a way for the Target MCU to access the file

    ASpar.1Author
    Visitor II
    March 24, 2021

    i forgot that, i'm an idiot :face_with_tears_of_joy:

    ASpar.1Author
    Visitor II
    March 24, 2021

    I saw that is possible using a SSD driver and specific functions to drive it by serial port. Could i load the txt file on an ssd and than the MCU could access to the txt by serial port. Is this a good solution?

    Super User
    March 24, 2021

    Surely, an SD-Card would be far simpler?

    Or USB stick - if your Target can do USB Host.

    You realise you can simply copy a file to a COM port on the command line ... ?

    Took a while to find - this is how the Target MCU can access the ST-Link's "dropped" files:

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