10 years, 6 months ago.

Cannot write any file into mbed disk.

Dear,

After installing winusb drivers and runing the DFUSec.exe to updated the latest firmware lpc4322_lpc1549_if_mbed_v0202_20140403.bin on my LPC1549 platform.

Then I can see the mbed disk and mbed serial port on my win7 laptop.

But I cannot write any file into the mbed disk, such as creating a simple txt file a.txt. When I try to create the a.txt file, the explorer exit automatically. And I also try to copy a a.txt file from my laptop into mbed disk, the explorer exit too.

Could you please help me on this issue?

Thanks a lot.

Question relating to:

Thank you all very much. It does work. I did ever do the same job on LPC1768 and just think the same operation for granted. Thanks again!

posted by jie zhao 20 May 2014

3 Answers

10 years, 6 months ago.

That seems normal.

The USB is disconnected and reconnected when a file is written to it (this is required with how USB drives are handled by an OS). If you got the folder open in explorer it autocloses when the drive is disconnected. I simply drag from another folder to the drive so that doesn't happen.

Then it can't do anything with a .txt file, just try a simple .bin file and see if that works. What you tried is possible on the LPC1768 mbed, since that has a seperate flash IC where you can write a .txt file for example on. But the 1549 directly programs the target.

Accepted Answer

As 1549 does not have external flash(LPC1768 had 2MB external flash) and only had on-chip flash, which should be 256KB from the data sheet, why it showed 512KB in the driver on PC? does 1549 have external flash as well?

posted by wei ying 20 May 2014

It might simply be a small error in the config data of the interface chip's code, which causes it to show up as too large drive. (There is nothing stopping you from showing your mbed as 1TB drive, windows will happily write to it, and actually show the data is their. Of course when you then replug it there is no actual data on it).

I wouldn't worry about it if it works fine.

posted by Erik - 20 May 2014

Hi Erik, I did the test and I could copy 256k bytes file into the mBed disk successfully and failed to copy a 285k bytes files into mBed disk. So you are right.

Here I have a little confusion. Usually the internal flash is a nor flash to keep the image file. We can use JTAG or other interface to flash the image file into the internal flash, then reset the board and the new image will be executed on the nor flash directly. However with mBed disk, it seems the interfnal Nor flash is exposed as mBed disk totally. After we copy the bin file into mBed disk, it seems MCU load the bin into other place. Even we repower board the bin file still can be exectued. And the mBed disk is still there without the bin file.

From my understanding, there is only one internal 256k bytes flash, which has been exposed to mBed disk totally. Then where is the bin file loded by MCU?

Thanks.

posted by jie zhao 20 May 2014

What you see isn't what is on the flash of the target, it is what the interface chip wants you to see. For example the mbed.htm file which should be on it by default, also doesn't recide on the target, but on the interface chip. When you upload a new file it will check if it is a .bin file, and if that is the case it will simply program the target block per block: It receives for example 512 bytes from your PC, it programs that into the target, and then tells your PC he can send the next block.

A slightly similar example I made myself. This is based on the standard mbed USB-MSD device code within USBDevice:

int ConfigDisk::disk_write(const uint8_t * data, uint64_t block) {
    if (block == 4)
        parseFile(data);
    return 0;
}

int ConfigDisk::disk_read(uint8_t * data, uint64_t block) {
    if (block < 4)
        memcpy(data, &disk[block*512], 512);
    else if (block == 4)
        createFile(data);
    else 
        memset(data, 0, 512);
    return 0;
}

I made here a very simply file system of only 5 sectors. If the PC wants to write to any except the last sector, it will simply return 0: Which means the PC thinks it has succesfully written data to it, but infact it was completely ignored. If it is to the last sector it parses the data in that package.

Similar if the PC wants to read from the first sectors, it copies data from a read-only array, unless it is the last block, then it dynamically creates a file which is supposed to be in that sector. (Actually it thinks there are a bit more than 5 sectors, and it returns zero for all others).

posted by Erik - 20 May 2014

It is very clear and I understand. Thanks you very much. :-)

posted by jie zhao 20 May 2014
10 years, 6 months ago.

I've the same or similar problem with an FRDM-K64F. If I compile a program, it starts to download to mbed but after a short while mbed window closes (it looks like it resets). When re-opened no download file is present on mbed disk.

Also intended behavior, it automatically will program the target, there is no permanent storage where your program stays on. Just make a simple program where you can easily check if it is running (after pressing the reset button obviously).

posted by Erik - 20 May 2014
10 years, 6 months ago.

You can only write .bin files to the drive. That file will be flashed into the processor. The bin file must have been produced by the compiler.

For the K64F, I use a SD Flash chip and SDFileSystem() That combo works for me. The Flash drive is not available to the PC. However, that's ok for what I'm doing.

...kevin

posted by Kevin Braun 20 May 2014