MQX Bootloader

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

MQX Bootloader

Jump to solution
4,248 Views
Tim562
Senior Contributor I

Hi Everyone,

 

    I'm trying to use the Freescale example bootloader application (MQX 3.8, CW 9.2) to load a ROM image of my application to an TWR-MPC-5125 target and boot to it. I'm able to directly load my app into the NAND Flash on the target and run it that way using the "ExtNand Download Release Target" but I want to use the bootloader so I can store multiple images (variations on my app) on the target and select one at boot time with the bootloader terminal prompt.

 

     I'm able to flash the bootloader into the target and have it run on a reset and use the a terminal interface and tftp to store an image to the target. Here's a screenshot of my terminal after using the bootloader to store an image of my application:

 

 

     I created the ROM image of my target as I believe the Freescale NAND Bootloader User's Guide (MQXBLDUG) specified with the RAM/ROM settings from the Linker Command File of my application. Here's a clip of the MEMORY section of the *.lcf file for my application showing the rom area located at 0x0001_0000 and the ram area at 0x0200_0000:

 

MEMORY { //Physical layout - hardware dependent //------------------------------------------------- SDRAM:           org = 0x00000000, len = 0x10000000 SRAM:            org = 0x30000000, len = 0x00008000 IMMR:            org = 0x80000000, len = 0x00100000 FLASH:           org = 0xFFF00000, len = 0x00800000 //Logical layout - change to suit application if required //------------------------------------------------- rom:             org = 0x00010000, len = 0x01FF0000 boot_rom:        org = 0x003FEF00, len = 0x00001000 ram:             org = 0x02000000, len = 0x08000000 kernel_data:     org = 0x0A000000, len = 0x05800000 nand:            org = 0x40000000, len = 0x00000000 // Page table memory //------------------------------------------------- page_tables:     org = 0x01000000, len = 0x0 //Physical memory backing the virtual context //------------------------------------------------- virtual_ram: org = 0x01200000, len = 0x0 //Cached vs. non cached region -  //------------------------------------------------- cached_ram:      org = 0x00000000, len = 0x0A000000 uncached_ram:    org = 0x0F800000, len = 0x00800000 }

 

     Here's a screenshot of the CodeWarrior EPPC Linker panel where the ROM image is spec'd. Note that I've specified the same address for ROM and RAM as in the Linker Command File for my application.

 

 

 

     So far this is all straight out of the Freescale NAND Bootloader Users Guide but I'm not able to make it happen. The bootloader runs as it should when the target hardware is reset. The bootloader finds the stored image I had previously downloaded and confirms the checksum is ok. After the bootloader completes it's 5 second countdown I'm assuming it's attempting to copy the image of my application to RAM and run it but the target just freezes up at that point and I have to reset it. Hitting a key before the 5 second countdown to prevent the bootloader from attempting to load my app allows me to interact with the bootloader using the terminal interface and I see my image but am not able to get the bootloader to run it.

 

     So much of this process is working properly that I'm sure I'm missing some small step but I can't figure out what it is. Note that I'm telling the bootloader to store my image at address 0x0000_0000 with the imgload command maybe that's not correct? I've tried several other addresses with no better results. I apologize for making such a long post but if anyone can offer any insight, advice, guidance or suggestions I would sure appreciate. Thanks!

 

~Tim

 

 

 

 

 

 

 

 

 

 

 

 

1 Solution
1,584 Views
Tim562
Senior Contributor I

Ahh, problem sovled!

 

     It turnes out that the address you instruct the bootloader utility to store the image at needs to be the address of the rom area in the Linker Command File of your application. Once I got that right it all started working great!

 

     Also, if you want to store multiple images for the bootloader to select from, you have the bootloader store them all at that same rom address value and the bootloader stores them in their own seperate areas in Nand Flash and they are refered to by a unique index value. Great stuff!

 

~Tim

View solution in original post

11 Replies
1,584 Views
shweta
Contributor I

Hey Tim,

I’m using TWR-MPC-5125 processor board. I’m trying to boot a simple application from nandflash using bootloader, I’m following the procedure given by freescale in MQXBLDUG.pdf (MQX 3.8 CW 9.2). I using the following hardware connections :

  1. J-tag to download the program.
  2. Ethernet connection for tftp.
  3. Serial to usb cable.
  4. Hyper Terminal.

As given in the procedure I created .bin file of hello world program, downloaded the bootloader example  with Ext NAND targets (have tried Ext Ram targets as well) to  get the shell prompt (shell>) in the hyper terminal and continued with the steps given in the manual. The image is been read (“HELLO WORLD”)at the end. Now on hard reset I neither get the image nor the autoboot count. I need to download the bootloader example application again to get the autoboot and the image (“HELLO WORLD”). I have tried using Ext NAND DOWNLOAD targets to download the hello world application and   bootloader application, its not booting from NAND on hard reset.  I feel I’m missing some step or have got the whole thing wrong!. Plzz get back to me asap on this.

~Shweta

0 Kudos
Reply
1,584 Views
Tim562
Senior Contributor I

Hi Shweta,

     I'm afraid I'm not much of an expert on this stuff. It sounds like your doing things properly. I use the Code Warrior USB Tap and compile to the "Ext NAND Download Release" target then use the "Run" command from CodeWarrior to download the compiled/linked application code and write it to the NAND flash. Once I've done that the target boots to that application on a powerup or reset. My application includes the bootloader code "bootloader.c" and "bootloader.h" so I can choose from multiple versions of my application stored in NAND flash at boot time. Perhaps you could try adding that to your application. Perhaps it's actually the code in the bootloader that runs first and copies your application code out of flash and into DDR ram then runs it. Not to sure of any of this, just things you might try. Good luck.

~Tim

0 Kudos
Reply
1,584 Views
shweta
Contributor I

Hey Tim,

               Thank you so much for your input, it was of great help. I still have few clarifications. I’ll first brief u up with how I went about with things. I used CW USB TAP,SERIAL_TO_USB bridge and HYPER TERMINAL. Once the connections was done I compiled/linked the bootloader application(MQX 3.8 CW 9.2) with the target as EXT NAND DOWNLOAD RELEASE and the RAM : 0x00400000 and ROM : 0x00010000 addresses both in Ext Nand Download Release Setting and the extnand.lcf file . Bootloader is successfully loaded to NAND FLASH. I get the prompt (shell>) in the hyper terminal on power on or reset.

        

          I load my application to NAND by tftp(Ethernet connection), steps followed as given in the procedure( MQXBLDUG.pfd) after I get the shell prompt in hyper terminal. My application was successfully loaded and booting on power on or reset.

            It works when I do the above, but I want to directly download my application to NAND without using tftp which I’m not able to. Since bootloader application is already present in NAND, i made the following setting for my application EXT NAND DOWNLOAD RELEASE target and the RAM : 0x00400000 and ROM : 0x00010000 addresses both in Ext Nand Download Release Setting and the extnand.lcf same as bootloader address, when  I run my application it goes to an unidentified machine instruction list. I have tired changing the ram and rom address both in the setting and in the .lcf file , but still I get that unidentified machine instruction list. I feel those instructions has got something to do with the ram and rom address which I entered. Another clarification is can I load multiple images directly to NAND using the EXT NAND DOWNLOAD RELEASE target? . Will appreciate your input on this. Thank you!

~ Shweta

0 Kudos
Reply
1,584 Views
Tim562
Senior Contributor I

Hi Shweta,

     I don't know of any way to install multiple images to NAND flash using Code Warrior. I wrote the ability to do that into my own application code. Basically I hijacked the code from the tftp process that writes a new image to NAND and tweaked it to work with my application. Part of my application is a web server used to configure the product and from that web interface the user can upload a new firmware image to my system. When my app receives that image from the web interface I write it to the NAND flash in the same fashion the the MQX tftp process does. It's a pain to implement but once you've got it working it's pretty convenient.

~Tim

0 Kudos
Reply
1,584 Views
shweta
Contributor I

Hey Tim,

            Thank you for your input Tim. May I know the “ram ” and “rom ” address which goes into the project setting and .lcf file for both bootloader and my application?. As far as I understood you have included bootloader.c and bootloader.h in your application and loaded it to NAND , so u have set “ram” and “rom” addresses once while loading it to NAND . I have not included bootloader.c and .h files to my application I have directly loaded bootloader application using  “Ext Nand Download Release” and “ram=0x00400000” and “rom=0x00010000” to NAND, it successfully boots from NAND. I’m not able to directly load my application using the same above setting or even after change of “ram” and “rom” address since bootloader is already present as said early. Can i directly load my application this way since I have loaded bootloader already if so, can you give any suggestion, insight on this? It would be of great help. Thank you!

~Shweta

0 Kudos
Reply
1,583 Views
Tim562
Senior Contributor I

Hi Shweta,

     My ram and rom settings in CodeWarrior are ram=0x0200_0000 and rom=0x0001_0000, Entry Point is set to "__nand_download" and "Use Linker Command File" is checked. I've pasted in the MEMORY section of the *.lcf file that I use for the "Ext Nand Download Release" target. Hope this helps.

~Tim

MEMORY
{

//Physical layout - hardware dependent
//----------------------------------------------------------------------------
SDRAM:           org = 0x00000000, len = 0x10000000 //256MB DDR SDRAM  = 0x0000_0000 to 0x0FFF_FFFF
SRAM:            org = 0x30000000, len = 0x00008000 //32K Internal SRAM  = 0x3000_0000 to 0x3000_7FFF
IMMR:            org = 0x80000000, len = 0x00100000 //1MB     = 0x8000_0000 to 0x800F_FFFF
FLASH:           org = 0xFFF00000, len = 0x00800000 //8MB FLASH    = 0xFFF0_0000 to 0x1_006F_FFFF (33 bit value?  )


//Logical layout - change to suit application if required (boot_rom needs to remain at 0x003F_EF00 else won't run)
//
//** boot_rom section being in the middle of the rom section may be a problem when the        **
//** objects placed in the rom section grow past 0x003FEF00 into the boot_rom section         **
//** this will happen when rom objects grow past 4,124,416 bytes in size                      **
//** Maybe can start the rom section after the boot_rom section at 0x003F_FF00 to 0x01FF_FFFF **
//** this would allow for 29,360,384 (0x01C0_0100) bytes in the rom section                   **
/----------------------------------------------------------------------------
                                        //SDRAM(unused)   =0x0000_0000 to 0x0000_FFFF (65,536 bytes)
rom: org = 0x00010000, len = 0x01FF0000 //SDRAM(<32MB rom)=0x0001_0000 to 0x01FF_FFFF (33,488,896 bytes - 4,096 byte rom overlap)
boot_rom: org = 0x003FEF00, len = 0x00001000 //SDRAM(4KB boot_rom)=0x003F_EF00 to 0x003F_FEFF (4,096 bytes - 4,096 byte rom overlap)
ram:         org = 0x02000000, len = 0x08000000 //SDRAM(128MB ram)  = 0x0200_0000 to 0x09FF_FFFF (134,217,728 bytes)
kernel_data: org = 0x0A000000, len = 0x05800000 //SDRAM( 88MB kernel) = 0x0A00_0000 to 0x0F7F_FFFF ( 92,274,688 bytes)
nand:        org = 0x40000000, len = 0x00000000 //NOSPEC(nand)   = 0x4000_0000 to ?


// Page table memory - 2MB for 256MB mapped If not using page tables, set len to 0
//----------------------------------------------------------------------------
page_tables:     org = 0x01000000, len = 0x0


//Physical memory backing the virtual context If not using virtual memory, set len to 0
//----------------------------------------------------------------------------
virtual_ram: org = 0x01200000, len = 0x0
 

//Cached vs. non cached region -
//Maps to logical layout above. the BSP will set up these  two regions
//if you need more, the BSP will need to set any addition regions up too
//----------------------------------------------------------------------------
cached_ram:      org = 0x00000000, len = 0x0A000000 //SDRAM (160MB cached_ram) = 0x0000_0000 to 0x09FF_FFFF (167,772,160 bytes)
uncached_ram:    org = 0x0F800000, len = 0x00800000 //SDRAM (8MB uncached_ram) = 0x0F80_0000 to 0x0FFF_FFFF (8,388,608 bytes)
}

0 Kudos
Reply
1,584 Views
shweta
Contributor I

Hey Tim,

               Need your input yet again!. Its all working well in freescale board using tftp. We have developed a custom board using the same processor MPC5125 and 1GB Nandflash. If i download the   nandflash_demo.c(nandflash example MQX 3.8)  given by freescale, i get a Reading error message in the Hyper Terminal i.e.,previously it would have erased and  written some data to Block 0 and 1 of nandflash.Its not able to read the same.Is it something to do with bad sectors?. But the same program is checking for bad sectors as well and there are no bad sectors..Its just not able to read.Need ur valuable input on this.Plz get back to me.

~Shweta

0 Kudos
Reply
1,584 Views
Tim562
Senior Contributor I

Hi Shweta,

     I'm sorry but I don't have any experience with using the nand flash for data storage (other then the firmware image storage routines). When I run into something like this I usually try stepping through the MQX functions and trying to understand what they are doing and how they're doing it. If you start with a working system (i.e the TWR Module) and follow through with the functions you should be able to learn what they are doing. Then try it with your custom board and see what's different. I'm assuming that you installed the same flash part on your custom board right? If not, there may be significant differences in the flash programming algorithms that are preventing the demo code from working. Good luck!

~Tim

0 Kudos
Reply
1,584 Views
shweta
Contributor I

Hey Tim,

               Thank you for your input.Yes its the same flash but with lesser memory space (1gb). I have brushed through the functions.I ll try yet again in detail and get back to you.Thank you!

~Shweta

0 Kudos
Reply
1,584 Views
shweta
Contributor I

Hey Tim,

               Thank you so much for your time and your valuable input. I'm working on transferring my application through serial port to NAND FLASH. As you said its a pain to implement!. Thank you once again.

~Shweta

0 Kudos
Reply
1,585 Views
Tim562
Senior Contributor I

Ahh, problem sovled!

 

     It turnes out that the address you instruct the bootloader utility to store the image at needs to be the address of the rom area in the Linker Command File of your application. Once I got that right it all started working great!

 

     Also, if you want to store multiple images for the bootloader to select from, you have the bootloader store them all at that same rom address value and the bootloader stores them in their own seperate areas in Nand Flash and they are refered to by a unique index value. Great stuff!

 

~Tim