Hi All,
I’m having a difficult time getting a new board that uses the MPC-5125 to run the bootloader (I’m using the bootloader that Freescale uses for the Tower module system). This board was designed by referencing the Freescale Tower module demo board and works properly under control of the CodeWarrior Debugger. The DDR memory, Ethernet system, LocalPlus Bus, SD card interface, etc, all work properly using the same Freescale BSP code as the TWR-MPC-5125 (as it was designed to). In fact the software for this project was originally developed using the Tower Module hardware (great idea by the way Freescale).
I have confirmed that the processor can properly read and write the NAND flash by storing images on it with the bootloader (running under debug control) and that the power on reset configuration (as set by the various bus pull ups and pull downs) is specifying a boot from the NAND flash device at 0xFFF0_0000 (8 bit mode), same as the Tower System.
I have a logic analyzer on the NFC interface and I am observing that the bootloader appears to be written to the NAND flash device when the CodeWarrior “Ext NAND Download Release” target is run. I also observe that upon a reset, the processor reads the boot header and bootstrap code from NAND Flash Block[0] then reads the image header and boot loader code from NAND Flash block[1], but the bootloader doesn’t run.
I had to spec a different Micron NAND Flash part (the one Freescale uses on the Tower module is obsolete) but the new part is still a 32Gb X 8 bit part that Micron recommended as a replacement for the original. I’ve tried booting with the original MQX NAND Flash defines statements, and I’ve tried changing them for the different page size, block size, etc values of the new part. Neither works. I have noticed that the MQX defines for the existing NAND Flash part were incorrect (yet they worked on the Tower module).
Has anyone been through this process before and can you tell me what changes you had to make to boot to a different NAND Flash part? Here are the Flash parts and the #defines that were used. Note that I tried the original MQX defines with the new flash parts as well as changing the #defines in the two files below to more accurately define the flash chip. Neither way seems to work. Are there other MQX files that I need to modify beyond the two I show below? Thanks for any suggestions.
Best,
Tim
-----[ Original Tower Module NAND Flash device and MQX #defines ]----------
NAND Part : Micron MT29F32G08CBABA
Page Size x8 : 4320 bytes (4096 + 224 bytes)
Block Size : 256 pages (1024K + 56K bytes)
Plane Size : 2 planes x 2048 blocks per plane
Device Size : 32Gb – 4096 blocks
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\twrmpc5125.h
#define BSP_FLASH_BASE ((pointer)0x0) /* block #0 */
#define BSP_FLASH_SIZE (0x400000)
#define BSP_FLASH_WIDTH (8)
#define BSP_FLASH_DEVICES (1)
#define BSP_VIRTUAL_PAGE_SIZE (2048)
#define BSP_ECC_SIZE (32) /* 32-error correction bits (60 ECC bytes) */
#define BSP_NAND_BLOCK_SIZE (512 * 1024) /* 512 KB */
#define BSP_NAND_NUM_BLOCKS (2048)
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\bsp_prv.h
#define NANDFLASH_PHYSICAL_PAGE_SIZE 2048
#define NANDFLASH_SPARE_AREA_SIZE 60
#define NANDFLASH_BLOCK_SIZE 524288
#define NANDFLASH_BOOT_PAGE_SIZE 0x3E4
#define NANDFLASH_BOOT_ECCBYTES 0x3C
-----[ Micron Recommended Replacement NAND Flash device and My Changed #defines ]----------
NAND Part : Micron MT29F32G08CBADA
Page Size x8 : 8936 bytes (8192 + 744 bytes)
Block Size : 256 pages (2048K + 186K bytes)
Plane Size : 2 planes x 1064 blocks per plane
Device Size : 32Gb – 2128 blocks
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\twrmpc5125.h
#define BSP_FLASH_BASE ((pointer)0x0) /* block #0 */
#define BSP_FLASH_SIZE (0x400000)
#define BSP_FLASH_WIDTH (8)
#define BSP_FLASH_DEVICES (1)
#define BSP_VIRTUAL_PAGE_SIZE (8192)
#define BSP_ECC_SIZE (32) /* 32-error correction bits (60 ECC bytes) */
#define BSP_NAND_BLOCK_SIZE (8192 * 256) /* 2,097,152 Bytes */
#define BSP_NAND_NUM_BLOCKS (2128)
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\bsp_prv.h
#define NANDFLASH_PHYSICAL_PAGE_SIZE 8192
#define NANDFLASH_SPARE_AREA_SIZE 60
#define NANDFLASH_BLOCK_SIZE 2097152
#define NANDFLASH_BOOT_PAGE_SIZE 0x3E4
#define NANDFLASH_BOOT_ECCBYTES 0x3C
Solved! Go to Solution.
Hi Tim,
The NAND flash part selected for my MPC5125 board is : MT29F2G08ABAEA (256 MB, 2k page + 64byts, 128k block). But board is not yet ready.
The only significant difference is: C = MLC type, A = SLC type Different capacities seem to be available for this series. According to MPC5125 Ref Man NAND boot section, any MLC or SLC type with: 1) 2k page + 64 spare byte 2) 4k or larger page is supported.
Visakhan
Hi All,
Checking the Micron website for the MT29F32G08CBACA part that Visakhan suggested indicates that it is also approaching EOL. I have samples on order anyway, but probably not a good move to start new product with this part. I'm showing two tables in this post that indicate the internal configurations for both parts (TABLE[1]) and the values of the MQX #defines in the 4 different source code files I've found that specify Nand Flash Parameters (TABLE[2]). You will notice that the default define statements do not accurately describe the original flash part on the tower module (resulting on some loss of max capacity, no big deal) but all works as it should.
Over the last week or so I have tried every combination of values correct to the replacement part and default values that I can think of with no luck. Some items I've maintained at there original values since I believe they are governed by the demands of the processor itself. These defines include:
NANDFLASH_BOOT_PAGE_SIZE 0x3E4
NANDFLASH_BOOT_ECCBYTES 0x3C
BSP_VIRTUAL_PAGE_SIZE 2048
BSP_ECC_SIZE 32
All other #defines have at various times been modified to the specifications of the new chip or left unchanged. So far no combination has worked. At this point I'm not sure what else can be done except to assume that this replacement flash part isn't compatible with the MPC-5125 NFC. Since the Micron parts that are compatible are approaching EOL does this mean that there is no compatible NAND Flash part that can be used with this processor? Anyone who has developed a product with this processor that boots from a NAND flash chip other then the original part spec'd on the TWR-MPC-5125 module, I sure would like to know what part you used. Best to all.
~Tim
TABLE[1]: Original (working) Micron Recommended
TWR-MPC-5125 Part Replacement Part (not working)
MT29F32G08CBABA MT29F32G08CBADA
----------------- -----------------
Device Bit Width : 8 Bits 8 bits
Page Size* : 4096 Bytes 8192 Bytes
Page Extra Bytes : 224 Bytes 744 Bytes
Pages Per Block : 256 Pages 256 Pages
Block Count : 4096 Blocks 2128 Blocks
Block Size* : 4096 x 256 = 1,048,576 8192 x 256 = 2,097,152
Blocks Per Plane : 2048 1064
Plane Size* : 1,048,576 x 2048 = 2,147,483,648 Bytes 2,097,152 x 1064 = 2,231,369,728 Bytes
Plane Count : 2 Planes 2 Planes
Device Size* : 2,147,483,648 x 2 = 4,294,967,296 Bytes 2,231,369,728 x 2 = 4,462,739,456 Bytes
Size In Gigabytes* : 4,294,967,296 Bytes is 4 GB 4,462,739,456 Bytes is 4.15625 GB
*Specified values do not include the extra/ecc bytes available to each page
TABLE[2]: Freescale MQX Freescale MQX
#defines Filename #defines Default Values
----------------- ------------ -----------------
Page Size : NANDFLASH_PHYSICAL_PAGE_SIZE bsp_prv.h 2048 (8192)
Page Extra Bytes : NANDFLASH_SPARE_AREA_SIZE bsp_prv.h 60 (744)
Block Size : NANDFLASH_BLOCK_SIZE bsp_prv.h 524,288 (2,097,152)
Boot Page Size : NANDFLASH_BOOT_PAGE_SIZE bsp_prv.h 0x3E4
Boot ECC Bytes : NANDFLASH_BOOT_ECCBYTES bsp_prv.h 0x3C
Flash Size : BSP_FLASH_SIZE twrmpc5125.h 0x400000 (4,462,739,456)
Device Bit Width : BSP_FLASH_WIDTH twrmpc5125.h 8
Flash Device Count: BSP_FLASH_DEVICES twrmpc5125.h 1
Virtual Page Size : BSP_VIRTUAL_PAGE_SIZE twrmpc5125.h 2048
ECC Size : BSP_ECC_SIZE twrmpc5125.h 32
Block Size : BSP_NAND_BLOCK_SIZE twrmpc5125.h (512*1024) (256*8192)
Block Count : BSP_NAND_NUM_BLOCKS twrmpc5125.h 2048 (2128)
Page Size : MT29F32G08_PHYSICAL_PAGE_SIZE MT29F32G08.c 2048 (8192)
Page Extra Bytes : MT29F32G08_SPARE_AREA_SIZE MT29F32G08.c 64 (744)
Block Size : MT29F32G08_BLOCK_SIZE MT29F32G08.c 524,288 (2,097,152)
Block Count : MT29F32G08_NUM_BLOCKS MT29F32G08.c 8,192 (2128)
Device Bit Width : MT29F32G08_WIDTH MT29F32G08.c 8
Page Size : NAND_FLASH_PAGE_SIZE nandbootloader.h 2048 (8192)
Block Size : NAND_FLASH_BLOCK_SIZE nandbootloader.h 524,288 (2,097,152)
Image Table BlkLoc: IMAGE_TABLE_BLOCK_LOCATION nandbootloader.h 8,000
Image Table PgLoc : IMAGE_TABLE_PAGE_LOCATION nandbootloader.h 2, 048,000
*(xxx) values are some values that I've tried based on the Micron spec sheet
Paths where TABLE[2] Files are located:
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\bsp_prv.h
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\twrmpc5125.h
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\io\nandflash\nandbootloader.h
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\io\nandflash\nand_devices\MT29F32G08.c
Hi Tim,
The NAND flash part selected for my MPC5125 board is : MT29F2G08ABAEA (256 MB, 2k page + 64byts, 128k block). But board is not yet ready.
The only significant difference is: C = MLC type, A = SLC type Different capacities seem to be available for this series. According to MPC5125 Ref Man NAND boot section, any MLC or SLC type with: 1) 2k page + 64 spare byte 2) 4k or larger page is supported.
Visakhan
Hi Visakhan,
Wanted to let you know that I settled on a 2GB Micron SLC part that is not EOL and actually works! The part is MT29F16G08ABABA. I have tried it on our board with the MPC-5125 and it works fine. Plus, with the SLC technology we go from 3000 Program/Erase cycles to 100,000 Program/Erase cycles. Since I'm only using the NAND Flash to store application images (< 4MB each) the capacity is still more than adequate. Thanks again!
Best,
Tim
Hi Visakhan,
I will give that series a look. I've sort of kicked this problem down the road by using the original MT29F32G08CBABA parts that were on the TWR-MPC-5125 module. They can still be had by the thousands so I'm good for several years with this. If I get backed into a corner I could always do a new board revision with a traditional parallel flash on the LocalPlus Bus (or try a different NAND flash manufacturer). Nothing I tried by way of NAND_FLASH_DEFINES allowed the 5125 to boot from the replacement Micron flash parts. I did notice that the new parts are significantly slower then the older parts (go figure) so maybe there's a timing issue. Thanks a lot for all your suggestions, I wish you the best of luck with your own projects.
Best Regards,
Tim
Hi all,
I've just had a really unpleasant thought regarding this failure to boot problem. I've been attempting to correct the problem by changing the values of the various MQX #defines that specify the NAND Flash device parameters BUT, doesn't the processor have to be able to read the bootstrap (from Block[0]) and Bootloader (from Block[1]) code out of the NAND Flash device into DDR memory using the MPC-5125 NAND Flash Controller power-on default settings? None of the MQX code that modifies the NFC for a particular flash device has any effect until after the Bootloader has been successfully read from NAND Flash into DDR and started running right?
As I understand it, the MPC-5125 and the NAND Flash device have to work together to read the boot code into DDR using the default power on NFC settings, right?
Since my product boots properly from the original MT29F32G08CBABA part, but not with the MT29F32G08CBADA replacement part, doesn't that mean that the MPC-5125 processor and this replacement NAND flash part are not compatible?
If this new part isn't compatible with the MPC-5125 can Freescale recommend one that is?
Thanks!
Tim
Hi Tim,
MPC5125 automatically loads the 2kB bootstrap code from block 0(4 boot pages), and executes it. This code is from bootstrap.c and boot.s. The changes done in NAND configuration affects bootstrap code since it uses these constants, and will take effect when you rebuild and flash the bootloader and boot from it. Next, this bootstrap code copies code from NAND(block 1) to DDR. This is also affected by the modified NAND flash parameters.
There is some error checking and retries done by NFC of MPC5125 when fetching the bootstrap code. If this fails, the bootstrap code will no execute. This can happen if the block 0 is bad block. Complete boot will not happen if Block 1 is bad.
The MT29F32G08CBADA seems to be the latest part but with different parameters as MT29F32G08CBABA. . There is MT29F32G08CBACA with same parameters as MT29F32G08CBABA. May be try that one.
Visakhan
Hi Visakhan,
I understand what your saying about the flash #defines affecting CodeWarrior's original writing of the bootstrap and bootloader code into the target. Thanks for that. That part you suggested looks perfect. I'll check into it and see if it's a viable part and post results back here. Thanks very much for your reply.
Best,
Tim
Hi All,
New info about this NAND Flash boot problem. I purchased a few of the original Micron NAND flash parts that are installed on the TWR-MPC-5125 module and installed them in my hardware. The new hardware product works perfectly now! Boot is immediate and correct every time. This seems to mean that this new Micron NAND part is either incompatible with the MCP-5125 NAND Flash controller or, (more likely) there are changes required to the MQX code to make the new flash part work. Does anybody know what changes are required to allow MQX to work with a different flash device?
I've tried changing the defines located in these files (and rebuilding MQX after the changes):
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\twrmpc5125.h
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\mqx\source\bsp\twrmpc5125\bsp_prv.h
C:\Program Files (x86)\Freescale\Freescale MQX 3.8.1.1\lib\twrmpc5125.cw\bsp\twrmpc5125.h
without any luck. Perhaps I just haven't hit on the correct values for the defines? One of the problems in changing these defines is determining what the new values should be. The original values work great for the original flash parts even though they do not accurately define these flash parts (wrong page count / size, block count / size, etc). So if the original values don't accurately define the flash part used, how do I know what values to use for a different flash device?
Maybe there's more then the three MQX *.h files listed above that need to be changed? Any thoughts on documentation I should be reading that might provide some guidance on what needs to be changed for new flash devices? Thanks for all the suggestions.
Best,
Tim
Hi,
There is one more file where NAND flash parameters are specified: (\mqx\source\io\nandflash\nand_devices\MT29F32G08.c). This is for the original flash on tower board
There is difference in actual flash parameters and MQX definitions, but it does not seem to cause problem. I think this is because the NFC controller handles it as long as these page size and block sizes are smaller than actual device parameters. Try using sae values for PHYSICAL and VIRTUAL page size both at 2048. and block size 256 times page size (512 * 1024)
Your new flash part seems to be compatible with MPC5125 mcu, as it is mensioned in the datashee, devices with page size of 1k/2k/4k/8k can be used for booting.
A note on the header files: Do not make any changes to files in \lib\twrmpc5125.cw\bsp. Only make changes to actual source files in \mqx\source\bsp\. On rebuilding bsp library, the \lib files are replaced with modified files in \source.
Visakhan
Hi Visakhan,
Thank you for your thoughts on this. I found the additional config file in the ...\io\nandflash\nand_devices folder just as you said. Changes to it were not effective. I had a pretty unpleasant thought this evening about why this isn't working and posted a message describing it. I'm not going to retype the whole post here, but in brief; I believe the 5125 and the NAND flash device have to work properly together at boot up without any configuration changes. Any configuration changes I can make to MQX won't take effect until after the Bootloader has been copied into DDR and is running. Since my product boots properly from the original MT29F32G08CBABA part, but not with the MT29F32G08CBADA replacement part, doesn't that mean that the MPC-5125 processor and this replacement NAND flash part are not compatible? I'm hoping that Freescale can recommend a flash part that will work to replace the obsoleted Micron part. Fingers crossed!
Best,
Tim
Hi Tim, this is not exactly what you are asking but FWIW, I am able to program NAND flash using BDI3000 with an internal tool and able to boot u-boot and Linux on it. If you later decide to go this avenue instead I can discuss the details. Thanks
Hi Sinan,
Thanks for your reply, If I need to do this (hoping not : ) I will post here. Have a great day.
Best,
Hi Tim,
The BSP_NAND_NUM_BLOCKS parameter will not make any difference, it specifies a limit to the bootloader.
I had some similar problems with the booting mqx bootloader on tower board. It was the CW TAP debugger that saved the day. It can be 'connected' to a running or halted processor, without starting a debug session. At powerup after the board seemed to be halted at boot, I used 'Debug>Connect' from codewarrior 9.2. This way we can view where the code is, it's dissassembly and any memory area. You also make sure whether all the code is copied to DRAM at proper place, if you know the bootstrap sequence and memory locations used. You can issue a reset from CW itself, to repeat this.
My problem was a change done in bootloader linker file, I changed mapping boot_rom section, which caused incomplete copying of bootstrap to NAND flash. This was tracked down with above method. One more problem is specifying a breakpoint at main, in the debugger setting of Ext nand download target, and using this to download bootloader to NAND. This will cause the bootloader to hang at main() itself, at powerup.
Regards,
Visakhan
Hi All,
I wanted to post an update on some new behavior I've observed. Using the original Freescale NAND Flash defines, the bootloader eventually runs! It takes quite a while after power is applied, but I'm seeing the bootloader run. The time after power is applied before the bootloader runs appears to be wildly variable. I've seen times ranging from 20-30 seconds to several hours, with a time of a few minutes (5 - 10) probably being the average. This adds additional credibility to the idea that the bootstrap/bootloader code are probably written correctly to the flash device by the CodeWarrior "Ext NAND Download Release" target (It appears it runs the bootstrap_ddr_to_nand() function from the bootstrap.c file to do this) but something is interfering with the process at boot time. Not sure where this discovery will lead but I will post any new information to this topic in case others encounter a similar problem.
Best Regards,
Tim
HI,
I am working on MPC5125 mcu, but still using the Tower module, since the target board is not ready yet. I have successfully booted the bootloader on Tower board only. But i have some suggestions:
Your changes to NAND flash #defines affects both bootstrap code and mqx bootloader. Take alook at bootstrap (/bsp/twrmpc5125/bootstrap.c). It uses some hardcoded values, my be valid only with tower board. It seems to me that, BSP_VIRTUAL_PAGE_SIZE should remain 2kB for mqx bootloader to work. So I suggest, the following values:
twrmpc5125.h:
bsp_prv.h
You say that you have run the bootloader using debugger and verified the NAND flash read and write. right?
On power on reset, where in the code, the board gets halted? Using the CW TAP you may be able to track this down.
- Visakhan
Hi Visakhan,
I tried your suggested values with the same results. I believe the only change you recommended from the default TWR-MPC-5125 code values was to change BSP_NAND_NUM_BLOCKS from 2048 to 1024. I'm curious why you suggested that change? And yes, you are correct, I have verified that NAND flash reads and writes work properly under debug control. At power on reset, the logic analyzer shows the processor reading the bootstrap code from block 0 (pages 0, 1, 2 & 3) then it shows the processor reading the bootloader image from block 1. At powerup, with the debugger not running and the logic analyzer my only "eye" into what's happening, it's hard to determine where the boot process is halting.
Some new behavior I've observed (using the original Freescale NAND Flash defines) is that the bootloader eventually runs! It takes quite a while after power is applied, but I'm seeing the bootloader run. The time after power is applied before the bootloader runs appears to be wildly variable. I've seen times ranging from 20-30 seconds to several hours, with a time of a few minutes (5 - 10) probably being the average. This tells me that the bootstrap/bootloader code are probably written correctly to the flash device by the CodeWarrior "Ext NAND Download Release" target (It appears it runs the bootstrap_ddr_to_nand() function from the bootstrap.c file to do this) but something is interfering with the process at boot time. Not sure where this discovery will lead but I will post any new information to this topic in case others encounter a similar problem. Thanks very much for your reply.
Best Regards,
Tim
Have a great day
We use u-boot for burning u-boot code to the NAND. See below.
We use u-boot from latest BSP for the TWR-MPC5125 board (http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPC5125&fpsp=1&tab=Design_Tools_Tab#).
1)”u-boot” file was renamed to “u-boot.elf” file
2) unrar the twr-mpc5125-pre-compiled-binaries.rar
The “u-boot-spl-2k.bin” and “u-boot-second-usb.bin” files were used from this .rar
3) copy the “u-boot.elf”, “u-boot-spl-2k.bin”, “u-boot-second-usb.bin” and “5125-TWR_init.cfg” files to “D:\BSP\tftpboot” folder.
4) Start a terminal program.
5) Start the CodeWarrior 9.2 for windows.
6) Click "File->Open" in CodeWarrior.
Open “u-boot.elf” file. See “Clipboard02.jpg” file.
Choose USB TAP. See “Clipboard04.jpg” file.
Press “Ok” on “Warning” message. See “Clipboard06.jpg” file.
Press “Cancel” if “Can’t find the file …” windows is appeared.
Set “Ignore all unknown files” and press “Ok”. See “Clipboard08.jpg” file. !
Set “CodeWarrior USB TAP” connection. See “Clipboard10.jpg” file.
Assign the “5125-TWR_init.cfg” file as “Target Initialization file”. See “Clipboard12.jpg” file.
Run this project. See “Clipboard14.jpg” file.
7) Stop autoboot in terminal window.
8) Start tftp program and assign this program to “tftpboot” folder. See “Clipboard16.jpg” file.
9) Program loader:
=> tftp 0x4000000 u-boot-spl-2k.bin
=> nand_e 0x00 0x01
=> nand_loader 0x4000000 0x00 0x800
=> nand_r 0x2000000 0x00 0x800
=> md 0x2000000
10) Program u-boot:
=> tftp 0x4000000 u-boot-second-usb.bin !
=> nand_e 0x100 0x1AD (since size of the u-boot-second-usb.bin file is 0x56260)
=> nand_w 0x4000000 0x100 0x56800
=> nand_r 0x2000000 0x100 0x800
=> md 0x2000000
See “Clipboard16.jpg” file.
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Pavel,
I'm going to stick with the MQX example bootloader for a bit longer before jumping ship and trying a new solution. It looks like the bootstrap and bootloader are being properly written to the NAND Flash device (using the CodeWarrior "Ext NAND Download Release" target) so I'm focusing on some boot time condition interfering with the bootloader process. I've managed to find a few samples of the original Micron NAND Flash device that is installed on the TWR-MPC-5125 module and I'm going to replace the NAND part on our board with that original flash device and see how that works. If it still doesn't boot properly then there's some difference in our hardware environment that's interfering with the boot process. If it does work, that tells me that I've got to make changes to the NAND Flash defines to get the bootloader to work with this new part. I'll be sure to post any results here. Thank you for your reply.
Best,
Tim