Author Topic: Error in running with const allocated over 128k of flash  (Read 13019 times)

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Error in running with const allocated over 128k of flash
« on: January 02, 2008, 03:50:39 PM »
I use MCF52233 (256k of flash) and Codewarrior 6.3
I have a program greater than 128k of flash and this problem:
If I compile from address 0 the program goes well.
If I compile from address 0x5000, because I have implemented a bigger bootlader (sd-card bootloader..), some const (that are allocated over 128k) result corrupted. I can say this because I see on the display some const (graphics) wrong. Variables are well shown on the display.

If I compile from addess 0x5000 and the program is less than 128k it goes well.

Code mode and data mode is already far (32bit)

Can someone help me?
best regards
Fabio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Error in running with const allocated over 128k of flash
« Reply #1 on: January 02, 2008, 06:38:43 PM »
Hi Fabio

A couple of questions.
1. Are you using the CW special edition with 128k limit or are you using a full version?
2. Is it possible that you are using the file system (or parameters) starting at an address which is overlapping with the end of the program?

Regards

Mark

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: Error in running with const allocated over 128k of flash
« Reply #2 on: January 03, 2008, 08:34:32 AM »
Hi Mark,
1- I think CW is full version because if I compile the 200k of program it goes well, without the bootloader.
2- If I compile a smaller file the program goes well with the bootloader. And I have looked to the flash memory and the bootloader is located in the first locations, and the program is the same in the two different version, it is only shifted of 5000 in the bootlader version...

My bootloader is a semplification of your SPIMODE. I use fyle system instead of the direct hardware command read/write of the spi eeprom..

I have looked to the Device errata, and I have noted you have setted the workaround 1 that is the best solution.

Is there some settings in utasker that reduce the program memory? due to the fact that a
part is for the web pages (I don't use http but it is enabled)
or some settings in the compiler/linker that you don't have considered because utasker don't exceed the 128k because in the FLASHMODE it is considered that the greater part is destinated to the program that must be copied by bootloader?

today I do many test...
Mark, best regards and many thanks to you

Fabio

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: Error in running with const allocated over 128k of flash
« Reply #3 on: January 03, 2008, 09:17:14 AM »
I have noted that it isn't a runtime error, it isn't an error of accessing the flash over the 128k.
But it is an error of the bootloader.
In the first location I have the code, in the higher memory I have the const, the const string that I use to draw the graphics in the display..and these, over the 128k, are written bad from the bootloader. It is very strange

Now I try to define these like "const far" or something of similar...
I don't understand...
bye
Fabio

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: Error in running with const allocated over 128k of flash
« Reply #4 on: January 03, 2008, 11:18:58 AM »
Perhaps there is some location that I mustn't overwrite, like the 0x400-418.
A register located in the middle of the flash...

I have noted that if in my bootloader I comment all the code, except the jmp 0x5000
(In other words if my bootloader make the only jump instruction to the application program) the application program doesn't go, if it is greater than 128k. If it is less than 128k it goes well.

I think this fact is important to say that it isn't a problem in bootloader but a problem in compiler/linker...some #pragma ...

my little brain is burning...:-)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Error in running with const allocated over 128k of flash
« Reply #5 on: January 03, 2008, 12:02:10 PM »
Hi Fabio

Only 2 restrictions come to mind.

Firstly it is correct that the address range 0x400..0x418 not contain code since the chip reads these at reset to determine the FLASH protection rules. It is best to have these set to 0 so that nothing is locked and no accesses restricted.

The second is not to use the original Freescale start up code which puts the value __FLASH in to FLASHBAR
http://www.utasker.com/forum/index.php?topic=40.msg175#msg175 / 4. 4.9.2007 FLASHBAR value with SPI FLASH bootloader support
If I understand correctly, you have already respected this. It can however have very strange results since undocumented bits may get set in a register which are possibly used by Freescale for testing...

I hope that you can work out what is going wrong!!

Regards

Mark





Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: Error in running with const allocated over 128k of flash
« Reply #6 on: January 03, 2008, 04:02:27 PM »
Great MARK !!!
I didn't update the SP5 with the service pack note...in particular the point 4. that you have signed in the previous message.

Now I want to understand the differences between the 2 versions..

THANK YOU VERY VERY MUCH

Fabio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Error in running with const allocated over 128k of flash
« Reply #7 on: January 04, 2008, 10:28:30 PM »
Hi Fabio

I understand that you managed to get the project working correctly with the change.

Unfortunataley I don't think that there is any publshed explanation for what you have seen since there are a few bits in the FLASHBAR which are described as 'not defined' in the data sheets and generally these MUST be set to '0' to ensure that everything works well.

One of these 'undefined' bits is however described in the errate to the M5223X since it controls the operation of the Internal FLASH Speculation. By setting a certain bit it is possible to disable this operation. It took some time to figure out why, when the original Freescale code is used to set up the FLASHBAR, DMA operation would fail when the start of program FLASH is not defined to be at address 0x00000000 or 0x00000800, but it has been proven that this was caused by setting certain other 'undefined' bits. You can also see the following explanation from when I was originally trying to work out what could be going on:
http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=3116&query.id=5537#M3116

My conclusion is therefore that these 'undefined bits' do indeed have some control functions, such as for testing the chip or controlling specific operations (possibly also for development purposes). This is however not documented - presumably because Freescale doesn't want all details to be known. In the case of the Internal FLASH Speculation in the first chips Freescale probably had no choice but to publicise the corresponding control bit.

Just make sure that no 'undefined' bits can get set and the there should be no problems!!

Regards

Mark