SD-card bootloader on MC9s08qe32 ?

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

SD-card bootloader on MC9s08qe32 ?

Jump to solution
2,508 Views
pabbott
Contributor II

Hello,

My application runs on the MC9S08QE32 and already reads and writes to an SD card (fat-lite driver).  I want the application software, during normal startup, to check for a file of a certain name, and if it exists, reprogram the flash with the contents of that file. 

I'll also display status of the upgrade on the LCD screen, if possible.

 

I've scoured the forums for an implementation of a bootloader that reads from an SD card.  Nothing exact, but I've found the following examples that may help:

  1. AN2295 Developer’s Serial Bootloader
  2. AN3561 USB Bootloader for the MC9S08JM60
  3. AN3927 Freescale USB Mass Storage Device Bootloader
  4. doonstack

It seems to me like #3 is the best bet and I'm going to start studying that one.  Can someone share some wisdom?

Thanks!

Labels (1)
0 Kudos
Reply
1 Solution
1,296 Views
pabbott
Contributor II

Got it!

I had to set FCDIV.

 

SD card bootloader: done!

 

I'll try to clean it up (and remove my proprietary code) and post the project when I get a chance.  It's an aweful hacked-up mess atm, but it works.

View solution in original post

0 Kudos
Reply
7 Replies
1,296 Views
pabbott
Contributor II

Well #3 looks like a good starting point, but there is no mention of Processor Expert.

My application is already written with heavy usage of PE.  How much trouble would it be to get PE to work with a bootloader?

0 Kudos
Reply
1,296 Views
pabbott
Contributor II

I found a helpful post about using PE with a bootloader. https://community.freescale.com/message/62534#62534

The chip can do hardware redirection of the interrupt vector, which is enabled in PE CPU bean. 

 

What I don't understand is what the "Reset Vector" parameter in the CPU bean is for.  What does it do? 

 

I'll have 2 projects. 

The bootloader project doesn't use interrupts, but interrupt redirection is turned on.  What to do with the reset vector parameter?

 

The application project is set up with the interrupt vector moved.  Perhaps the reset vector is relevant here? 

Isn't this entry point setup in the prm file?

0 Kudos
Reply
1,296 Views
pabbott
Contributor II

Well I'm getting closer...

I think everything is working up until the actual flash programming.

Stepping through the code, it branches to the RAM and tries to program the flash.  But the flash remains FF.

Maybe the programming code is not appropriate for this chip?  How do I re-generate it for the QE32?  Also, is there a constraint on the CPU clock?

 

/********************************************************************
*********************************************************************
*     Flash subroutines
*********************************************************************
********************************************************************/

const unsigned char FLASHPGM_ROM[59] = {  
0x87,0xC6,0x18,0x25,0xA5,0x10,0x27,0x08,0xC6,0x18,0x25,0xAA,0x10,0xC7,0x18,0x25,
0x9E,0xE6,0x01,0xF7,0xA6,0x20,0xC7,0x18,0x26,0x45,0x18,0x25,0xF6,0xAA,0x80,0xF7,
0x9D,0x9D,0x9D,0x9D,0x45,0x18,0x25,0xF6,0xF7,0xF6,0xA5,0x30,0x27,0x04,0xA6,0xFF,
0x20,0x07,0xC6,0x18,0x25,0xA5,0x40,0x27,0xF9,0x8A,0x81};

/*  The opcode above represents this set of instructions  
    if (FSTAT&0x10){                     //Check to see if FACCERR is set
        FSTAT = FSTAT | 0x10;            //write a 1 to FACCERR to clear
    }
    (*((volatile unsigned char *)(Address))) = data;  //write to somewhere in flash
    FSTAT = 0x80;                        //Put FCBEF at 1.
    _asm NOP;                            //Wait 4 cycles
    _asm NOP;
    _asm NOP;
    _asm NOP;
    if (FSTAT&0x30){                     //check to see if FACCERR or FVIOL are set
    return 0xFF;                         //if so, error.
    }
    while ((FSTAT&0x40)==0){             //else wait for command to complete
        ;
    }*/

0 Kudos
Reply
1,297 Views
pabbott
Contributor II

Got it!

I had to set FCDIV.

 

SD card bootloader: done!

 

I'll try to clean it up (and remove my proprietary code) and post the project when I get a chance.  It's an aweful hacked-up mess atm, but it works.

0 Kudos
Reply
1,296 Views
MICROAR
Contributor I

can you share your code or part of it?

0 Kudos
Reply
1,296 Views
MDeDonato
Contributor II

I am looking to do an SD card bootloader for the K10, can you post your code for me to take a look at?

0 Kudos
Reply
1,296 Views
SIS
Contributor I

Hi Pabbott

I am going to do a SD CARD BOOTLOADER on the QE32  and I have seen that you already done it.

Please can you tell me if there are some APPNOTE about it or how did you arrive to do it?

Thanks and best regards.

0 Kudos
Reply