bootloader (AN4368) Keil port crashes during Flash access

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

bootloader (AN4368) Keil port crashes during Flash access

Jump to solution
1,063 Views
swtat
Contributor II

Hi

I would like to build the bootloader project of AN4368 for TWR-K60D100M using Keil MDK. The zip file contains only projects for IAR and CW. Porting the code seems to be a bit tricky since there are a lot of compiler switches (__CWCC__ or __IAR_SYSTEMS_ICC__). I get hundreds of warnings and errors.

Is there an existing port or a guideline on how to port bare metal projects to Keil?

Thanks,

andy

Tags (3)
0 Kudos
1 Solution
629 Views
swtat
Contributor II

The bootloader works. It had been two issues:

collisions (RDCOLERR):

uLinkPro seems to cause this fault. Without debug everything works fine.

crash of the bootloader:

The following bug in diskio.c led to the crash:

Index: diskio.c

===================================================================

--- diskio.c (revision 92)

+++ diskio.c (revision 140)

@@ -238,7 +238,7 @@

  {

   /* Send read_capacity SCSI command */

   bCallBack = FALSE;

-  status = usb_mass_ufi_format_capacity(&pCmd, (uchar_ptr)&read_capacity,\

+        status = usb_mass_ufi_format_capacity(&pCmd, (uchar_ptr)&capacity_list,\

     sizeof(CAPACITY_LIST));

   if ((status != USB_OK) && (status != USB_STATUS_TRANSFER_QUEUED))

   {

View solution in original post

0 Kudos
2 Replies
628 Views
swtat
Contributor II

Well, first step is done.

I downloaded CW10.4 (10.2 would have been a better choice?!). The bootloader did not run out of the box. With some changes the bootloader works with CW10.4: PIT1_kinetis (Timer initialization) and I had to take USB Lib V4.11 instead of the enclosed USB lib. The USB lib from the example code didn't run with CW10.4.

Next step was porting to Keil. I can build the code using Keil. Porting was not such a big deal at least to reach the stage of building: startup files, some compiler specific code (inline assembler) and so on.

Now I still have a problem. The bootloader starts the application or reads the file from stick, erases flash but crashes during flash programming. The bootloader resets the uC. I don't see any exceptions with the tracer.

In flash_FTFL.c Flash_ByteProgram() function I can see that the RDCOLERR bit is set in FTFL_STAT. If I step through with the debugger the bit is not set. What could be the reason that this flag is set using Keil compiler. The flag is not set with code built with CW10.4.


I removed all USB and PIT-timer code to avoid IRQs.The behaviour is the same. In additon it crashes during the erase of the flash. => timing problem?

As far as I understand the bootloader, the code is not executed from RAM, right? At least in CW I see the PC pointing to flash adresses. I guess it has something to do with my project settings.

In the meantime I found AN 4552 (Porting your code to uVision). I think I followed those instructions more or less. I did not take vector.c from the CW code but took startup_MK60N512VMD100.s from the USB lib Keil example. My code and vector table is located in flash.

attached you will find the map-file.

The project settings (TWR-K60D100M):

target.jpg

linker.jpg

Thank you for your help,

andy

0 Kudos
630 Views
swtat
Contributor II

The bootloader works. It had been two issues:

collisions (RDCOLERR):

uLinkPro seems to cause this fault. Without debug everything works fine.

crash of the bootloader:

The following bug in diskio.c led to the crash:

Index: diskio.c

===================================================================

--- diskio.c (revision 92)

+++ diskio.c (revision 140)

@@ -238,7 +238,7 @@

  {

   /* Send read_capacity SCSI command */

   bCallBack = FALSE;

-  status = usb_mass_ufi_format_capacity(&pCmd, (uchar_ptr)&read_capacity,\

+        status = usb_mass_ufi_format_capacity(&pCmd, (uchar_ptr)&capacity_list,\

     sizeof(CAPACITY_LIST));

   if ((status != USB_OK) && (status != USB_STATUS_TRANSFER_QUEUED))

   {

0 Kudos