AN4379 cannot bootload a program > 25 kB

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

AN4379 cannot bootload a program > 25 kB

11,804 Views
nicholasf
Contributor III

Hi,

I am trying to use AN4379 (USB device bootloader) for a project, but after transferring ~24576 bytes, there is a problem, and an error causes the bootloader to stop.  This error will not occur with the AN4379 sample project, as the application file being transferred is not large enough to cause this issue to arise.

The problem is that the 'MSD_Event_Callback' (in the 'disk.c' file) function is reading the first part of the file a second time, causing an 'invalid file' error, and terminating the process.  I have tested this problem extensively, and it is very clear that after transferring 24576 bytes, the data buffer passed to 'MSD_Event_Callback' contains the beginning of the file again ("S0030000FC" in my case).

I have no real idea as to what is causing this error, but it seems likely that the host is re-transmitting the file for some reason; perhaps the transfer was not correctly acknowledged in previous communications, or the device is requesting a re-transmission.

Any input or solution is very much appreciated, and thanks for reading this post.

Labels (2)
0 Kudos
Reply
5 Replies

1,054 Views
mjbcswitzerland
Specialist V

Hi

Which processor are you using? HS or FS USB?

- If you use a USB analyser you can better see whether the host is repeating data, however I don't believe that that will be the case since a USB-MSD host will not repeat data - each packet (64 bytes in FS mode) is delivered (and repeated if necessary, but very rarely) by the USB controller and so the host will assume that each packet is delivered (or else the link will already fail)

- Are you sure that the SREC file that you are using is not corrupted? (Have repeated SREC addresses in it?)

- You can get pre-build USB-MSD loaders for most board here: µTasker Test Software and Demos

- Also if you don't manage to solve the problem with the AN4379 version you can get a proven and supported USB-MSD loader (for all Kl and K devices) from KINETIS Project Code which will build with CW, KDS, IAR, Keil, Rowley, Coo Cox, Atollic, GCC standalone or VisualStudio (for simulation). I believe that it has more features (shows the file's name, date and time each time the disk is connected, can read back code from boards, with optional password protection) and may be much smaller (about 12k) than the AN4379 code if it is true that it uses 47k.
Depending on you exact boot loader requirements it can be configured to operate in various modes (alone or in parallel) - see Re: Kinetis Boot Loader for SREC UART, SD Card and USB-MSD loading for an overview and links to its documentation and a video showing it in operation. It can be used with applications from any source.

In case you need to use the AN4379 version and still don't find a quick answer I have USB debugging facilities to help in case of urgency.

Regards

Mark

1,054 Views
nicholasf
Contributor III

I am using a 120MHz-capable K20, running at 96 MHz, and using full-speed USB.

- I agree that it seems unlikely that the host is repeating data, but the only alternative explanation (I can think of) is that there is some sort of error related to the microcontroller's buffer.

- The .S19 file I am using is fine; I have looked through it, and there is no repeat of the header (which is the problem observed in the microcontroller).

- I cannot use the pre-built bootloaders listed on the " µTasker Test Software and Demos" site, because my application is much larger than any of those allow, and I require some other custom features.

- I am currently looking in to the "Kinetis Project Code", but am unsure of how long it would take to modify this for my intended use.

Thanks for the links, and the insight; I am fairly certain that the issue is some sort of bug in the bootloader's code, but I have not been able to what it is, or where it might be.

-Nick

0 Kudos
Reply

1,054 Views
mjbcswitzerland
Specialist V

Nick

What extra features do you require?

You should find the "Kinetis Project Code" easier to adapt than the AN4379 code since it uses a small OS which makes it simpler to control in a modular fashion (the USB-MSD code is all in usb_loader.c) and also it allows the project to be simulated with Visual Studio so developing, testing and debugging is much easier and efficient. Furthermore the project is supported and so in case of questions you can get immediate help.

Regards

Mark

0 Kudos
Reply

1,054 Views
nicholasf
Contributor III

Hi Mark,

The system for which I am developing is complex, and I have already finished and integrated the code to manage the rest of it.  The only thing that I have left is to resolve this bug, which I found very late, because I had only boot-loaded small files until now. This is why I prefer to fix AN4379, rather than jumping to a different code base.

-NickF

0 Kudos
Reply

1,054 Views
mjbcswitzerland
Specialist V

Nick

OK. I thought you were in need of a boot loader but it sounds like you have integrated the AN4379 as part of an application which can't be separated.

Are you sure that the USB clocks are accurate? Do you run the processor at 96MHz rather than 120MHz for a specific reason? Both 96MHz and 120MHz allow accurate USB.

It will be interesting to hear what the problem was and how you fixed it, including the time it takes. If it is a problem with the AN4379 code maybe you can get Freescale to solve it - why not file a service request?

Regards

Mark