USB MSD Host for the FRDM-K20D50M Board

The Freedom boards FRDM-KL25Z RevE and FRDM-K20D50M make it easier to use it as USB Host device, as they come with a special jumper to provide 5V to the USB device, so my earlier ‘hack’ is not needed any more :-). After I had USB MSD Host working for the FRDM-KL25Z, it was much harder to get the USB stack working for the FRDM-K20D50M board, because somehow the example Freescale provided with their USB stack refused to work properly on my board. After debugging it for several nightly hours, I decided to take my working Processor Expert project for KL25Z and added support for the K20. And the good news is: since tonight this is working :-).

FRDM-K20D50M as USB MSD Host

FRDM-K20D50M as USB MSD Host

USB Host Jumper

By default, the FRDM boards do not supply 5V to the USB connector. But that 5V is required to attach a device like memory stick to power the MSD device from the host (the FRDM board). On the FRDM-KL25Z RevE I can set a jumper to provide the 5V to the bus:

USB Host Jumper on the FRDM-KL25Z RevE

USB Host Jumper on the FRDM-KL25Z RevE

A similar jumper is present on the FRDM-K20D50M board:

FRDM-K20D50M with USB Host Jumper

FRDM-K20D50M with USB Host Jumper

Example Application

The example application runs a command line shell over OpenSDA virtual COM (USB CDC):

FRDM-K20D50M with USB MSD Host

FRDM-K20D50M with USB MSD Host

USB enumeration is shown with a RGB LED which blinks either green or red. As file system the application runs FatFs. Below are some points to consider if you want to build your own application from scratch:

Clock Settings

The clock needs to provide 48 MHz to the USB peripheral. As the FRDM-K20D50M has an external 8 MHz crystal, I configure this in the CPU settings:

FRDM-K20D50M configured to use 8 MHz Crystal

FRDM-K20D50M configured to use 8 MHz Crystal

The clock is configured for PEE mode to produce an 48 MHz PLL output:

MCG in PEE mode with 48 MHz PLL Output

MCG in PEE mode with 48 MHz PLL Output

The System Clocks are configured as below:

System Clocks

System Clocks

❗ Do not forget to set the PLL/FLL clock choice to ‘PLL clock’ with 48 MHz, otherwise USB will *not* work. I missed that myself, and have lost many hours of debugging :-(.

Processor Expert USB Component

The FSL_USB_Stack Processor Expert component is configured as below:

FSL_USB_Stack Component Settings

FSL_USB_Stack Component Settings

The FSL_USB_MSD_Host component settings only needs to know for which CPU it is:

FSL_USB_MSD_Host Component Settings

FSL_USB_MSD_Host Component Settings

MSD Host Application

I’m using a FreeRTOS task to perform the USB processing with interrupts:

/*
 * host.c
 *      Author: Erich Styger
 */

#include "host.h"
#include "msd_commands.h"
#include "CLS1.h"
#include "FRTOS1.h"
#include "FsMSD1.h"

static void print(unsigned char *str) {
  CLS1_SendStr(str, CLS1_GetStdio()->stdOut);
}

static void CheckStatus(void) {
  switch (FsMSD1_GetDeviceStatus()) {
     case USB_DEVICE_IDLE:
       break;
     case USB_DEVICE_ATTACHED:
       LEDR_Off();
       LEDG_On();
       print((unsigned char*)"Mass Storage Device Attached\n" );
       break;
     case USB_DEVICE_SET_INTERFACE_STARTED:
       break;
     case USB_DEVICE_INTERFACED:
       break;
     case USB_DEVICE_DETACHED:
       LEDR_On();
       LEDG_Off();
       print((unsigned char*)"\nMass Storage Device Detached\n" );
       break;
     case USB_DEVICE_OTHER:
       break;
     default:
       print((unsigned char*)"Unknown Mass Storage Device State\n");
       break;
  } /* switch */
}

static portTASK_FUNCTION(HostTask, pvParameters) {
  (void)pvParameters; /* not used */
  for(;;) {
    FsMSD1_AppTask();
    CheckStatus();
    FRTOS1_taskYIELD();
  }
}

void HOST_Init(void) {
  FsMSD1_HostInit();
  if (FRTOS1_xTaskCreate(HostTask, (signed portCHAR *)"Host", configMINIMAL_STACK_SIZE+100, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) {
    for(;;){} /* error */
  }
}

That’s it 🙂

Summary

With this I have now USB MSD host working for the FRDM-K20D50M. The most complicated part is to set up the clock settings which are not that simple. But after knowing what needs to be done, this is pretty easy, especially with the help of Processor Expert. All the sources are as always available on GitHub, and this particular example project is available here.

Happy MSDing 🙂

63 thoughts on “USB MSD Host for the FRDM-K20D50M Board

  1. Pingback: Review: New FRDM-KL26Z Board | MCU on Eclipse

  2. Hello Erich,

    I’ve been working with this configuration on the FRDM-K20D50M and had some good results. Maybe except the “Interrupt Request” setting in the “Init_USB_OTG” for the MSD Host setting that absolutly needs to be Enabled to work (somehow the project works right out of the box with this setting disabled, but then nothing works when you try to make one from scratch and don’t enable this setting…). I have made a Frenken-FRDM and changed the cpu for a MK20DX256VLH7 which gave me some hurdles to surpass but now is working great (OpenSDA prog and debug). The only trouble I’m having is with the benchmark function, which throws me into HardFault for writting at a null pointer I think. It crashes in the “FAT1_CopyFile”, in the first “FAT1_open” (source file) and in the FreeRTOS part where a call for “prvCopyDataToQueue” the “vTaskPriorityDisinherit” tries to “uxListRemove” because “if( pxTCB->uxPriority != pxTCB->uxBasePriority )” has some weird priority numbers in it. For having it checked with a working project on a non-Frenken-FRDM board, the priorities are “1” because they come from the tasks created with “tskIDLE_PRIORITY+1” (I assume) but I have no idea why these numbers are changed to weird one or how to check when they get “corrupted”. I suspect buffer overflow somewhere or stack overflow but only because it couldn’t really be something else. Also, do you have any advice on how to make this component more reliable? Seems I get a lot of “low level errors” and some “ERROR: getcwd failed: (13) There is no valid FAT volume on the physical drive” the first time I try a DIR command or DELETE from the Shell component. Do you have the same troubles with other platforms because even with the stock FRDM D20 I get some errors with some more “reliable” usb thumb drives. Once again thank you very much.

    Mevon

    Like

    • Hi Mevon,
      try to increase the stack for your tasks using the file system. This usually helps a lot. I know that if there is a problem with FatFS, it is hard to debug it, but I have not found a better way.
      Erich

      Like

      • Hi Erich,

        Thanks again for replying, I am really greatful of the time you give for this. I have tried to increase the many stacks in the project with no success. Could you be more precise as to where and which ones to increase? I have tried incrinsing the one in the FSL_USB_Stack to 4096, Free_RTOS to 8192, and even the stack size and heap size in the build options of the cpu. The only place I see it could be different is in the “FSL_USB_MSD_Host” component where there is only an option for the K20D50 Cpu and not the K20D72 one I use. I am assuming that there are no real big difference in the PEx component you created because the 50 and 72 are really close hardware wise. Any other help would be greatly aprreciated and thank you for your great work. I spread the good word about you and hope you continue this help. Thanks again.

        Mevon

        Like

        • From the FreeRTOS perspective, the 50 and 72 are the same (just Cortex M4). But that might not be the case for the USB part (I would need to check, but higher frequency Kinetis sometimes have a different USB block). Have you increased the stack size of the tasks too?

          Like

      • Interestingly enought, it seems I have no troubles adding a new task with the “Vanilla” project on the stock FRDM, and with the new project I created, adding a new task makes it crash with FreeRTOS. I will try reverting all the stack size like in the original one, maybe it will help.

        Mevon

        Like

      • I think my troubles are related to the .LCF file generated by the PEx CPU component. I used the “reset to default” option which gave me something “working” ok but now I find maybe it as some flaws. Can you help me design a good MK20DX256.LCF that would work with FreeRTOS?

        Pweeeeeeaaase? Pwetty pwetty pweeaasssseeee? 😀 ty

        Mevon

        Like

      • Ok got it working, seems the Linker Config File generated is ok with defaults of PEx. I put 500 more bytes in the Shell task and now it’s working. Thanks

        Mevon

        Like

  3. Hi Erich, I really will owe you a beer pack for all the help you have given me… But I have been pushing my luck with the FRDM and tried to overclock the MCG to 96MHz. Thing is now the USB MSD part seems to be broken. I’m guessing it has tto do with the usb stack but could you give me your thougts on where I could begin to check this out? Thank you very much.

    Mevon

    Like

    • When I use a 96 MHz PLL in the cpu component, it looks like the interrupts for the USB stack are not generated. Also, when increasing the FreeRTOS stack for the “Host” task, it seems that going over “+350” bytes at task creation makes it crash. My “Totalt heap size” is 16384 in the FreeRTOS component and my “m_data_20000000” size is 32768 bytes in the “Build options” of the cpu component. My “DATA_BUFF_SIZE” for the USB stack is 4096 bytes. Running with these settings works but the USB is not loading any MSD as host. Can you try with your stock FRDM-K20D50M and change the clocks to work with a 96Mhz PLL (48Mhz USB clock with divide by 2 prescaller)?

      Mevon

      PS: Heres my size from elf file:
      “C:/Freescale/CW MCU v10.6/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-size” –format=berkeley -t FRDM-K20D72M_MSD_Host.elf
      text data bss dec hex filename
      75188 16444 5140 96772 17a04 FRDM-K20D72M_MSD_Host.elf
      75188 16444 5140 96772 17a04 (TOTALS)

      Like

    • Update: running at 48MHZ the “usb_hast_ch9_dev_req” in “host_ch9.c” gets called subsequently and doesn’t wait that much after the first case “REQ_SYNCH_FRAME” passed but in 96Mhz, almost 10sec can pass before another request arrives with “devreq_ptr->BREQUEST” = ‘ÿ’. At 48Mhz, another “REQ_SYNCH_FRAME” arrives right after, and maybe two others before a “USB_ATTACH_EVENT” comes and the MSD gets mounted.

      Like

    • So I got it !!!!! (YAY!!!) I see you had the problem too and from what I see it’s a ProcessorExpert bug (maybe you can bring it to your ppl at freescale and get a promotion, I will give the answer to you, all just for you 😉 ) I changed some lines in the USB0.c generated in the init usb function, here is what I did:

      void USB0_Init(void)
      {
      /* SIM_CLKDIV2: USBDIV=1,USBFRAC=0 */
      SIM_CLKDIV2 |= SIM_CLKDIV2_USBDIV(0x01);

      /* SIM_SCGC4: USBOTG=1 */
      SIM_SCGC4 |= SIM_SCGC4_USBOTG_MASK;

      Seems here the settings for SIM_SCGC4 needs to be done AFTER the settings for the SIM_CLKDIV2. Also, I changed the “Core Clock Prescaler” to 96MHz, and the “Reference Clock Divider” to 4 so I get the “PLL Reference Clock” at 2MHz in the Cpu Component. (Maybe these last two are not needed…) Merry Chrismas my brother 🙂

      Mevon

      Like

    • PS: Also there is something cheezy going on in the “usb_bsp.h” : #if (defined MCU_MK20D7) || (defined MCU_MK40D7)
      #define MCGOUTCLK_72_MHZ
      //#define MCGOUTCLK_48_MHZ
      #endif

      #ifdef MCGOUTCLK_72_MHZ
      #define SYSTEM_CLOCK ((uint_32)72000000)
      #else
      #define SYSTEM_CLOCK ((uint_32)48000000)
      #endif

      #define BUS_CLOCK ((uint_32)(SYSTEM_CLOCK) / 2)

      I didn’t see anywhere where the “BUS_CLOCK” was used but it kinda doesn’t work anymore when the MCG Clock gets changed to another freq. Best regards,

      Mevon

      Like

      • Yes, these cheezy stuff is part of the Freescale USB stack. I have not cleaned up that part. But I’m now wondering what your problem was (or is), because I don’t have that. But it seems that I have a different problem (with my project on GitHub): the USB memory steck gets properly detected when I plug it in, but FAT1 dir only works ok the first time. If I do it again, I run into huge timeouts. Not sure what this is causing it 😦

        Like

      • Hi Erich,
        From what I see it’s all because I use a MK20DX256VLH7 and try to overclock it to 96MHz. Somehow the SIM_SCGC4 before the SIM_CLKDIV2 (like PEx does by default) brings mayhem to the clockings and the usb stack lags extensively. My usb init function I’ve supplied above works for me (just copied the USB0.c into “source” folder and left out the “Code_Generated” one of the compiled resources). Also, I changed the “#define SYSTEM_CLOCK ((uint_32)72000000)” part for “#define SYSTEM_CLOCK ((uint_32)96000000)” for it to work, didn’t work without it. Another thing I did is give 0x1000 to the heap in the Cpu Component but I didn’t noticed major changes (maybe not needed). Hope this helps bring the Freescale a little further for everyone!
        Mevon

        Like

        • Hi Mevon,
          thanks for the additional information! I’m using a normal clock configuration, so must be something different. For me the USB operation stalls sometimes for 10-30 seconds which is not good, as it does not allow stable operations. I keep digging. Thanks!

          Like

        • Ok, I think I’m finally grasping the problem you see (sorry, sometimes it takes me a long time to realize that too ;-). And only until I ran into the same problem, it gets clear to me… The thing is that I was confused what you meant with ‘overclocking’. Actually, this is not overclocking, but you (as I tried) is to get a clock higher than 48 MHz into the USB peripheral. I understand ‘overclocking’ to run something outside the specification. But using a clock higher than 48 MHz as clock source is inside the specs. Anyway, I see now on my MK22 processor that indeed the line with SIM_SCGC4 and SIM_CLKDIV2 needs to be swapped in order to work. I have not found anything in the data sheet indicating this :-(. But I’m wondering why you had to change the SYSTEM_CLOCK value? It is not used anywhere in the sources I have?

          Like

      • Hello Erich,

        By overclocking I mean using the CPU at 96MHz, my usb clock is still at 48MHz (I use a 2 divider in the Init_USB_OTG component created by the FSL USB Stack PEx comp). I really don’t know neither why I need to set the right value for that define because me too I didn’t find it referenced anywhere else, hence the cheezy qualifier 🙂 I just know that if I use a cpu clock over the specified 72MHz of this MK20DX256, the usb does not respond. Also note the other modification I had to do in the USB0 init function, noted above. From what I understand, if we don’t set the divider before the clock source I assume, the USB does not respond and llooks like in a faulty state or wrong setting. Thanks for all this great work you do and share with us all, thank you very much!

        Mevon

        Like

        • At least for my K22F120 I only had to exchange the two lines in the Init() function, and then it worked. I used CodeWarrior for MCU10.6 for this. I checked as well the Processor Expert Driver Suite (I have in my DIY Eclipse), and I had it updated to the latest PEx Release 10.4.1, and here the code is correct. So obviously this is fixed, but not in CW 10.4 it seems.

          Like

  4. Hello, Just checking, as this project is created in CodeWarrior – should it import into KDS 1.1?
    (https://github.com/../Examples/FRDM-K20D50M/FRDM-K20_MSD_Host)
    It seems I get problems with different toolchains, directory paths and startup files.
    Maybe simple to change to KDS tools environment. but may also be a can of worms – any thoughts.?

    Like

  5. I tried to run the example project and FAT_FileSystem PE component can’t find the Drive: https://drive.google.com

    Actually, if I start a project form scratch, and try to add FAT_FileSystem component, it gives me the same error. I’m using Ubuntu 14.10 and KDS2.0.0.

    Can you give me any hints on what can I do to discover where is the problem.

    Best regards,

    Jerônimo

    Like

  6. Hello Erich,

    I’ve been following this tutorial and “USB MSD Host for KL25Z” tutorial to configure TWR-KL46Z48M board as USB MSD host using FSL_USB_Stack component.

    I’ve changed CPU component,clock settings and pin configurations for TWR-KL46Z48M in your GitHub example project Freedom_USBHostMSD. Running the code with #define ONLY_HOST 1 option in host.c file.

    Now every time I run the code, it breaks out from USB_DEVICE_IDLE case in CheckStatus() function, OTG connector is not getting 5V VBUS and board is not able to recognize USB device attached to it after initialization.

    My current jumper settings for TWR-KL46Z48M are:
    J18: 1-2 -> P5V_KL46_USB
    J20: 1-2 -> KL46_USB_ENABLE
    J21: 1-2 -> KL46_USB_FLGA

    What am I missing here? 😦

    Like

  7. Hi, Erich

    I got some errors when I tried to import your project in CodeWarrior v. 10.6:

    How can I fix those errors?

    ‘configCOMMAND_INT_MAX_OUTPUT_SIZE’ undeclared here (not in a function) ‘cOutputBuffer’ defined but not used [-Wunused-variable] CommandInterpreter.c /FRDM-K20_MSD_Host/Generated_Code line 107 C/C++ Problem

    Description Resource Path Location Type
    mingw32-make: *** [Generated_Code/CommandInterpreter.o] Error 1 FRDM-K20_MSD_Host C/C++ Problem

    Description Resource Path Location Type
    mingw32-make: *** Waiting for unfinished jobs…. FRDM-K20_MSD_Host C/C++ Problem

    Thanks and best regards,

    Marco Coelho

    Like

      • Hello, Erich

        I just followed your instructions. That error disappeared, but another one took place now:

        Description Resource Path Location Type
        RTOSTICKLDD1.h: No such file or directory RTOSTICKLDD1.h: No such file or directory Events.h /FRDM-K20_MSD_Host/Sources line 55 C/C++ Problem

        Should I be missing something?

        I suspect I’m experiencing some kind of corruption in FreeRTOS installation files.

        I’m trying to reinstall it and start it over again.

        Thanks,

        Marco Coelho

        Like

        • Hi Marco,
          no need to uninstall things! Is this include in Events.c/Events.h or main.c? Simply remove that #include, because sometimes Processor Expert does not clean it up.

          Erich

          Like

    • Hi Marco,
      that’s really strange 😦
      In which files are these wrong #includes?
      In the FreeRTOS component settings, do you have Scheduler>Systick enabled?

      Otherwise: you might send me your project zipped to the email address mentioned in the About box of this blog, and I might have a look at it tomorrow morning my time.

      Like

  8. Erich,

    Weird things are happening here!

    After commenting “includes” related to RTOSTICKLDD1.h file, I rebuilt the code and I got the following errors:

    Description Resource Path Location Type
    ‘NVIC_ICER’ undeclared (first use in this function) USB1.c /FRDM-K20_MSD_Host/Generated_Code line 66 C/C++ Problem

    Description Resource Path Location Type
    ‘NVIC_ICPR’ undeclared (first use in this function) USB1.c /FRDM-K20_MSD_Host/Generated_Code line 81 C/C++ Problem

    Description Resource Path Location Type
    ‘NVIC_ISER’ undeclared (first use in this function) USB1.c /FRDM-K20_MSD_Host/Generated_Code line 82 C/C++ Problem

    I can’t understand! Those registers are defined in MK20D5.h file, which is present in my project. I tried to force an inclusion of this file. But, the errors remain!

    I’m using the project you posted in Freescale Community.

    Thanks,

    Marco Coelho

    Like

  9. Taking the oportunity, Erich. We are looking for a bare metal demo code for MK20DN256 with Processor Expert. Can we use those same beans in baremetal (without O.S.). We are not very experienced with O.S. So we’d rather work in baremetal instead.

    Thank you!

    Marco Coelho

    Like

    • Hi Marco,
      I don’t have a ready example, but yes, you can use the components in bare metal (no OS) mode. Although I would say things like USB (especially host mode) are a lot easier to do with tasks.
      Erich

      Like

      • Hello, Erich

        Thanks for your upload in Freescale Community. Now I could get it running on my FRDM-K20D50M.

        I just programmed and tested your MSD demo in my FRDM-K50D50M and it is not working. The demo scrolls down on the Terminal. But I typed all the commands and failed.

        I tried to format my USB memory stick and start over again, but no way to work!

        I don’t what I should be missing here.

        Thanks.

        Like

        • Hi Marco,
          In that new project on the Freescale community, there is an S19 file included as well. Can you try with that one, just to be sure that your hardware is working?
          I tried on my side with my board, and it works properly. Can you try with different memory sticks? Try an older/smaller one, as I have seen reports that sometimes USB3 or huge memory sticks can cause problems. And: have you set the jumper on the board to provide 5V to the USB as a host?

          I hope this helps,
          Erich

          Like

        • Additionally, I have received reports that memory sticks >= 4GB have a problem. So far in my projects I have used sticks with less than that size. I quickly tried a 8 GB stick, and indeed I see a problem mounting it. Maybe this is the problem you have?

          Like

  10. Hey Erich Nice work,
    Keep it up the good work.
    I am using USB host with KL25z with Fatfs library.
    It works well for a while(on an avg. 20 hrs or so ) then suddenly.stops writing file when I looked up into it then I found out that f_open returns FR_DISK_ERR (1) this seems stange to me.
    this keeps happening even I press reset button on board.
    until I power down and power up again.
    please try help me out. at least tell me how do I debug to rectify this issue any document or anything. please help I am lost don’t know where to look.

    NOTE. Sorry I accidentally put the comment on wrong page previously

    Like

    • Thanks 🙂
      There could be many reasons for an FR_DISK_ERR. So you are using MSD host with a memory stick? Is the file system still OK on that device? What are you doing? Are you adding more and more data to the device? I have heard about problems if a file size goes over 2 GB or more than 2 GB are used on the memory device, but I was unable to verify/reproduce this.

      I hope this helps,
      Erich

      Like

      • yes I am using Memory stick of 4GB
        yes file system is ok if I use this device for 2hrs it gives perfect output and files are perfect,
        I am writing string recieved from serial port
        yes sir I am more data but the length of sting is same(less than 1kb) always to device so size of file is arithmatic proression.
        no file size is not at all more than 2GB its not even 100MB yet

        I am doing
        fopen
        flseek
        fwrite
        close

        Like

        • I don’t see anything wrong with that. I only can speculate that it might be something going wrong in the USB stack. I would suggest that you try to isolate the problem as much as possible. And for the error case that you add some logging inside FatFS. Keep it running with the debugger and have some breakpoints set in important places when things go wrong. This kind of things. Not easy, but the only thing I see how to get to the root cause.

          Like

        • another idea: make sure you have plenty of stack space for the application and the interrupts available. Simply to remove the possibility of a stack overflow problem.

          Like

      • yes you are right I have debugged it and found that my code somehow eats up the memory.
        I have put Cpu_systemreset() where there is chance of getting this issue
        also added printline before task create so what I found is that when the condition arises it reseted but doesn’t create task
        cause it did not have printed line which was there in task

        So I have tried to reset it with button on board but it always print the same line before task create.
        Now I have concluded that it doesn’t create task.
        is it because I did not use TaskDELETE with task handle
        but to my understand it should start from main of program and should clear all the memory of stack and heap
        is it depend on freertos heap memory allocation scheme 4 does it help
        Question will you please help me deciding how much stack and heap I should assign.

        Like

        • Can you use a debugger instead of printline or something like that? And I’m confused why you would need to delete a task? Typically this is not necessary at all: create the task needed and then have them running. You need to understand your system very well or having a special use case that you need to delete a task.

          Like

      • I think there are two possible root cause.
        1) task creation not taking place
        2) stack overflow occours and its not taken care of.

        Both sinarios are converging to one issue there is stack overflow oocur so please suggest me some links or documents or tricks with which I can identify as well as rectify this issue

        Like

      • Hey I have checked printing there is no memory leak
        I have printed heap before and after task it is constant 176
        and maximum stack usage is 468 bytes

        and it gives error in seeking file
        file size is arounf 4.8MB
        I don’t understand.
        I have notised that when I unpug and replug the Pen Drive it starts working

        Like

        • Good, so we have at least checked that. To me out sounds that either the Freescale USB stack (somehow?) has a problem, or the pen drive. I assume you have already tried it with different pen drivers, different brands? Otherwise I think only a USB protocol analyzer will be able to narrow down the issue.

          Like

      • I tried 4 different pen-drives but of same brand sandisk.
        but no success and protocol analyzer is not in my reach.
        so some how USB gets disconnected or de-registered automatically. so that cannot write or open file.
        or something else
        this FR_DISK_ERR tells us some thing is wrong at low level.

        but I expect it to run when disconnected and reconnected.
        but it needs hard reset to USB to start working again.

        Like

        • you might try to call USB1_Deinit() and then USB1_Init() again, with initializing everything?
          I’m affraid that without using a USB protocol analyzer you won’t be able to solve that problem.

          Like

    • Hi erich
      I got a lead the lead I have checked return value of f_open when it fails it is always 1
      some times it is f_seek that returns 1
      SO when I digged in I found out it is FR_DISK_ERR
      it is disk io error.
      will this be helpful to debug

      Like

  11. Hi Erich,

    I was trying to merge this demo with this other of yours:
    https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fmcuoneclipse.com%2F2013%2F04%2F28%2Fserial-bootloader-for-the-freedom-board-with-processor-expert%2F but I´m facing a strange problem here when I add the IntFlash component: There is no way I can erase a sector using the IFsh1_EraseSector method, when I read the value returned for the method I allways got a “ERR_VALUE” or 0x03. Do you have any idea to help me to solve this issue?

    Like

    • Doing flash programming while the USB stack is running might be problematic, as usually the interrupts are turned off.
      As for the error value: I’m affraid that you have to debug it and step through the code to see what is going wrong.

      Like

      • Solved! I must set to the following clocks:

        Clock frequency: 120MHz
        Core Clock, Bus Clock and External bus clock: 60MHz
        Flash Clock: 20MHz.

        In my project I´m disabling all interrupts while erasing or writing the flash and enabling it right after that.

        Like

  12. I am trying to implement this project but I getting an error while configuring the FSL_USB_Stack Processor Export component. When I try to select FSL_USB_MSD_HOST, CW gives me an error saying “Cannot create FSL_USB_MSD_HOST inherited component/template.” I have removed it and re-imported it and even started a new project but still get stuck on the same error. I am new to the NXP line and would appreciate any help.

    Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.