Utasker USB-MSD with TWR K60F120M

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Utasker USB-MSD with TWR K60F120M

Jump to solution
2,864 Views
williamcarlisle
Contributor II

I am having issues getting the USB-MSD functionality of the Utasker bootloader going. I am using KDS with a PE debugger.

I have tried several different configurations and the K60 always shows up as "unknown device".

I have followed the gobs of documentation spaghetti, and twisted myself into knots trying to figure this out.

I have gotten the serial interface to work, and can view the menu and send commands.

The documentation for this link, page 15 is where I am at.

http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

What I am stuck at now is:

In Loader.h there are three defines that configure the USB-MSD boot loader operation:

#define ROOT_FILE_ENTRIES 4 // when USB MSD loader, this many directory

                                entries are set to the start of FLASH -

                                the application start is shifted by this

                                amount x 32 bytes

#define ENABLE_READBACK // allow USB to transfer present application to PC

#define READ_PASSWORD "enable file read from the device by dragging this file

                              to the disk" // password with maximum length of 512 bytes

Funny thing is when I am using the "uTaskerV1.4_FLASH" build configuration, Loader.h is not available.

When I use "UtaskerSerialLoader_FLASH" build configuration, there is no define for USB_MSD:

#if defined DEVICE_WITHOUT_USB

    #define NUMBER_USB     0                                             // no physical queue needed

#else

  #define USB_INTERFACE                                                // enable USB driver interface

    #if defined USB_INTERFACE

      #define HID_LOADER                                               // Freescale HIDloader.exe or KBOOT compatible

            #define KBOOT_HID_LOADER                                     // select KBOOT mode of operation

        #undef _NO_CHECK_QUEUE_INPUT

      //#define USB_HOST_SUPPORT

        #if !defined HID_LOADER

            #define SUPPORT_FLUSH                                        // allow flush command to be used (important for mass storage class)

        #endif

I have been round and round with this so-called "out of the box bootloader" far too long, and any help I can get would be greatly appreciated.

Thanks in advance!

1 Solution
2,264 Views
mjbcswitzerland
Specialist V

William

The default configuation is to use the 50MHz clock input.

On TWR-K60F120 J18 should be OFF

On TWR-SER:

- J2 3-4 (selecting 50MHz clock for the PHY and the backplane)

- J3 2-3 (enables 50MHz clock to drive the backplane line CLOCKIN0)
- J12 9-10 (for Ethernet RMII) - not important for USB

- J6 7-8 (for PHY IRQ) - not important for USB

The USB's 48MHz clock is derived from the this clock via a PLL.

If the clock is not as expected things may still run (at incorrect speed) and USB will fail.

1. Check that the LED is blinking with exactly 5Hz (100ms half-cycle period). If the wrong clock is used also the main time base will be out.

2. Try loading the reference build from the TWR-K60F120M link since this allows USB to work on the standard K60F120 tower kit - if it doesn't run it will presumably be a HW config. If it runs then there is a problem with the build.

As noted before I did the steps on a standard K60F120 tower kit with KDS3 and the drive appeared as expected. I have attached the binary output (you can find yours in \Applications\uTaskerSerialBoot\KinetisDesignStudio\uTaskerSerialLoader_FLASH) so that you can do a "diff" on it to also ensure the build is identical (it is 31'107 bytes in size).

Good luck!

Regards

Mark

View solution in original post

12 Replies
2,264 Views
mjbcswitzerland
Specialist V

Hi William

Guide for uTaskerV1.4.7 public version  for USB-MSD on TWR-K60F120M:

1. Import project into KDS 3.0 (or older KDS version)

2. Select "uTaskerSerialLoader"_FLASH target

Note: There is a funny with KDS (Eclipse) where the uTakerSerialBoot application directory may still be displayed grayed-out. This is cosmestic but can be solved by changing a KDS setting as discribed here:http://www.utasker.com/forum/index.php?topic=1883.0

It will however still build and operate correctly even if not done.

3. In the file Applications\uTaskerSerialBoot\config.h select the board TWR_K60F120M

4. In the same file enable USB device operation with #define USB_INTERFACE and disable HID_LOADER if you don't want USB KBOOT and then it will default to USB-MSD

5. In the KDS project properites ensure the compiler is setup to match the K60F120. See the KDS guide at http://www.utasker.com/kinetis/compilers.html#KDS in case of difficuties.

Essentially ensure the core is Cortex-M4 (and not Cortex-M0+) and use the linker script file K_1M_128.ld.

6. Build and load

7. The red LED D7 will flash at 5Hz when the serial loader is running.

8. Connect the PC to the USB socket on the TWR-SER board to see the loader appear as an external hard drive called UPLOAD_DISK

9. Drag a binary image of the application to be loaded to the disk (linked to the correspondng start address) so that it loads and then runs

What can go wrong?

a. Don't disable SERIAL_INTERFACE otherwise the application will be located at 0x2800 and so the loader will see code there (the USB loader is larger than this location) and so will try to jump to it and crash. Holding SW2 down at reset will however force the loader to operate. If SERIAL_INTERFACE is to be rmoved the start location can be adjusted accoringly in Loader.h with the define UTASKER_APP_START.

b. If there is already code in the K60 before loading the serial loader it will depend on the IDE/debugger/setting whether it is fully deleted or not. If not deleted the serial loader may detect it and try to jump to it. Holding SW2 at reset will force the loader and it is advisable to do a chip erase before loading the serial loader.

c. If the serial loader works but your application doesn't, see the following for possible reasons: http://www.utasker.com/forum/index.php?topic=1869.0

See also http://www.utasker.com/kinetis/TWR-K60F120M.html for pre-build loader for the TWR-K60F120M and a few kit details.

Note: I think that you have downloaded the public V1.4.7 version which supports either KBOOT or USB-MSD (the registered user versions allow mixing multiple device modes if desired and includes all features as in the documents)

I just tested the above sequence with the public V1.4.7 version in KDS3.0 and on the TWR-K60F120M and found it to work as expected. Assuming you can solve the probelm with the steps above please indicate what the problem was so that any details can be made more clear.

It is also advisable to build and test the loader from its VisualStudio project and run its Kinetis simulator since any setup errors can then be seen without needing to debug on the HW.

Regards

Mark

0 Kudos
Reply
2,264 Views
williamcarlisle
Contributor II

Also, there are so many jumpers between the k60 board and the twr-ser board - I cant be sure these are all set correctly. I found the "recommended jumper settings" document, that mentioned 3 or 4 jumpers between the two boards.

0 Kudos
Reply
2,265 Views
mjbcswitzerland
Specialist V

William

The default configuation is to use the 50MHz clock input.

On TWR-K60F120 J18 should be OFF

On TWR-SER:

- J2 3-4 (selecting 50MHz clock for the PHY and the backplane)

- J3 2-3 (enables 50MHz clock to drive the backplane line CLOCKIN0)
- J12 9-10 (for Ethernet RMII) - not important for USB

- J6 7-8 (for PHY IRQ) - not important for USB

The USB's 48MHz clock is derived from the this clock via a PLL.

If the clock is not as expected things may still run (at incorrect speed) and USB will fail.

1. Check that the LED is blinking with exactly 5Hz (100ms half-cycle period). If the wrong clock is used also the main time base will be out.

2. Try loading the reference build from the TWR-K60F120M link since this allows USB to work on the standard K60F120 tower kit - if it doesn't run it will presumably be a HW config. If it runs then there is a problem with the build.

As noted before I did the steps on a standard K60F120 tower kit with KDS3 and the drive appeared as expected. I have attached the binary output (you can find yours in \Applications\uTaskerSerialBoot\KinetisDesignStudio\uTaskerSerialLoader_FLASH) so that you can do a "diff" on it to also ensure the build is identical (it is 31'107 bytes in size).

Good luck!

Regards

Mark

2,264 Views
williamcarlisle
Contributor II

Thanks much Mark!

It ended up being the jumper on the twr-ser board, - J3 2-3. The jumper was on 1-2.

Now everything pops up like it is supposed to, seems like it must be user error(not that that ever happens : } ).

pastedImage_1.png

Thanks again!

0 Kudos
Reply
2,264 Views
mjbcswitzerland
Specialist V

Hi William

Good to near its working - use the previous links to ensure compatibility with your application if you don't use the uTasker application.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K60: http://www.utasker.com/kinetis/TWR-K60N512.html / http://www.utasker.com/kinetis/TWR-K60D100M.html / http://www.utasker.com/kinetis/TWR-K60F120M.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

:smileyinfo: Out-of-the-box support for 46 Kinetis boards and 10 IDEs (460 combinations from a single code source with no porting required)

0 Kudos
Reply
2,264 Views
williamcarlisle
Contributor II

Mark,

The uTasker USB-MSD bootloader is popping up , and appears to be functioning correctly.

The problem I am having now may be a memory/startup location issue:

I can build a project and drop it's .bin file into the "UPLOAD_DISK", at which point the window goes away and appears that the bootloader goes away(heartbeat led stops). I then push reset to run my project, and the code does not run -The bootloader isn't restarting, indicating it is trying to run my code.

If I play with memory locations in the linker file of the application I built, this will change things - but haven't figured out what the right values are.

Here are the defualts for the Application Linker File:

pastedImage_1.png

And here is my latest try in modifying this

pastedImage_0.png

And here is the uTasker Linker File:

pastedImage_2.png

I flashed the application I built without the bootloader and it ran fine, so I am almost positive that the configuration of memory is off somewhere.

I appreciate any help I can get to move this along, thanks in advance!

0 Kudos
Reply
2,264 Views
mjbcswitzerland
Specialist V

William

You need to move yout reset/interrupt vectors from 0x00000000 since this space is occupied by the boot loader.

Effectively your m_interrupts must be at 0x8080 and not just your m_text (which can follow it). Note that 0x8080 is not a valid address to run interrupts from and the simpest method is to relocate interrupt vectors to RAM (this is also an option in PE).

The reference uTasker linker script to compare is K_1M_128_BM.ld (found in the uTaskerV1.4 project and not in the serial loader) since it is designed to link a project to operate together with the loader. The K_1M_128.ld is for the serial loader itself or a stand-alone application.

To test that your loader is really working use a reference application from http://www.utasker.com/kinetis/TWR-K60F120M.html which will run (LED blinks at 2.5Hz and there will be various menus on the UART, the Ethernet will run TELNET, FTP and a web server, serving from the SD card and maybe it will connect via USB as USB-CDC - I don't remember the exact reference configuration).

You will also find that when you force the USB-MSD loader mode again the loaded software will show up on the disk drve with its file properties (data, length etc.).

In case it doesn't work it may be that you are using MAC OS X or WIndows 8.1, which the public version is not compatible with (you need pre-Windows 8.1 or to disable its new search mode in the registry).

The story of the problem with USB-MSD and newer OSs is explained here: http://www.utasker.com/kinetis/USB-MSD-MAC.html and it is normal that "older" versions can't work with Windows 8.1 and co. without redesigns (mbed, P&E drivers also failed until they did the same update).

The reference serial loader at the TWR-K60F120M page can also be used to veriy that the HW is Ok since it has compitibility with the new OSs.

Regards

Mark

0 Kudos
Reply
2,264 Views
williamcarlisle
Contributor II

Mark,

All right, I know the bootloader is configured right, I can load and run the "uTaskerV1.4.8_BM_TWR-K60F120M_8080.bin" example file just fine.

So it looks like my issue is with the application configuration. Could you post the configuration/memory/linker settings used from the "uTaskerV1.4.8_BM_TWR-K60F120M_8080.bin" example? I followed through with the configuration from your reply, but my code is not running when loaded like the example does.

Here is the linker file settings from the application I am trying to run:

pastedImage_0.png

I feel I am close because I am able to load the example, but something is off in my application that I need help with.

Thanks again!

0 Kudos
Reply
2,263 Views
mjbcswitzerland
Specialist V

Hi William

The settings look good although it is not absolutely clear whether PE does it correctly because, with vectors in RAM, only a 0x10 long reset vector is actually needed.

If you post the binary* that you are loading I can load it to my board and tell you why it is failing.

Attached is the linker script that I use to build TWR-K60F120M applications that work with the loader.

Regards

Mark

*To attach files switch to "Use advanced editor" and then the use "Attach"

0 Kudos
Reply
2,264 Views
williamcarlisle
Contributor II

I am still having trouble getting this going, but I am so close its driving me crazy!

As requested, the binary from my code is attached.

Thanks for working with me on this!

0 Kudos
Reply
2,264 Views
mjbcswitzerland
Specialist V

William

The binary that you are generating is not correct because it doesn't have a reset vector at the start. I don't know why because the linker script seems fine.

I would look at your map file (attach it too) because the location of the reset vector should be included and you can then find out where it has been put - then it should be possible to work out why the environment is doing things differently to expected.

Below is a screen shot of your binary in a hex editor compared with a reference application.It shows just the start of the file and represents the content as big-endian long words (the endian has to be swapped to read addresses):

pastedImage_2.png

Your file is the top one and you can see that the first two long words, which should be the initial stack pointer value followed by the initial program counter values, (where the code starts) are quite random and are clearly invalid addresses.

The lower one has SP = 0x2000fffc (top of SRAM) and 0x0001b0b5 (starting location in Flash) which are clearly valid ones.

If you compare your standalone build (linked to 0x00000000) you will also see that the reset vectors must be normal since it also wouldn't be a able to run with such values.

Regards

Mark

P,S You can also generate a complete TWR-K60F120M application to load by simply selecting the target "uTaskerV1.4_BM_Flash" in the same KDS project. In fact it includes much more that PE can generate and is all tuned up to work in productive environments (including simulation of the Kinetis device) so could generally allow you to solve your complete project in a much short time.

0 Kudos
Reply
2,264 Views
williamcarlisle
Contributor II

I am still having issues getting the "UPLOAD_DISK" to show. I restarted my project following you instructions above to a tee, and this is what I get:

pastedImage_0.png

pastedImage_1.png

After trying the instructions outlined above, I checked into the links you provided. Here are my relevant project properties:

pastedImage_3.png

pastedImage_4.png

And here is my linker file:

pastedImage_5.png

So I am still stuck on this, I appreciate the help and hope to have this up and running soon.

Thank you!

0 Kudos
Reply