gcc compiler error / ASF error???

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a Problem with the Atmel Studio 7.0.1931 when I make a Project with Atmel SAMC21 with 256 kB Flash and using the ASF 3.38.0 to get the NVM Driver of the ASF.

 

The Problem is that I don't understand what happens with this Code below...

When I compile the Code I get the Messages:

Severity

Code

Description

Project

File

Line

Error

 

Lichtbalken.elf section `.text' will not fit in region `rom'

Lichtbalken

 

1

Error

 

region `rom' overflowed by 4 bytes

Lichtbalken

 

1

Error

 

ld returned 1 exit status

Lichtbalken

collect2.exe

0

Error

 

recipe for target 'Lichtbalken.elf' failed

Lichtbalken

E:\PROJECTS\BLUM\Easystick\Lichtbalken\Lichtbalken\Lichtbalken\Debug\Makefile

594

 

void _SubModul_write_data_to_flash(void)

{

uint8_t i;

uint8_t page_buffer[NVMCTRL_PAGE_SIZE];

enum status_code errorCode;

 

nvm_get_config_defaults(&config_nvm);

config_nvm.manual_page_write = false;

nvm_set_config(&config_nvm);

 

do{

errorCode = nvm_erase_row(0x0003ff00); //row_page_0_start_address);

}

while(errorCode == STATUS_BUSY);

//start of problem

for(i = 0; i < NVMCTRL_PAGE_SIZE; i++)

{

page_buffer[i] = i;

}

//end of problem

 

do{

errorCode = nvm_write_buffer(0x0003ff00, page_buffer, (uint16_t)NVMCTRL_PAGE_SIZE);

}

while(errorCode == STATUS_BUSY);

 

while(1) { };

}

 

This is a test Code, because the other write operations into the Flash also don't work / I'm not able to get them compiled.

The idea is to Setup a Buffer with the number from 0 to 63 with the loop of "i" and then write them into the Flash at the 4th last page of the Flash.

 

Interssting is that I can Change the line "page_buffer[i] = i;" to "page_buffer[i] = 0x00;" and then the Compiler works fine and in the Flash there the values are stored.

 

At the Moment I don't understand the Problem, because when I set the line to "page_buffer[i] = (uint8_t)i;" it also don't work.

 

I have start the Project normal with the Atmel Studio and used the ASF Wizard to get the needed Modules.

Do you have there some idea? Maybe the Problem is in the "collect2.exe" of the ASF?

 

Thank you for taking the time to help me.

 

Best regards

Michael

 

 

This topic has a solution.
Last Edited: Sat. Nov 17, 2018 - 03:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What else is in your project? I can't think the code you show here is the problem, it looks very similar to the nvm example code, did you try that project?

/Lars

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Lars,

 

after much time of searching I think I have found the reason for this Thing.

 

I found a linker file in the ASF section called "samc21e16a_flash.ld" with the entry off:

 

OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")

OUTPUT_ARCH(arm)

SEARCH_DIR(.)

/* Memory Spaces Definitions */

MEMORY

{

rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000

ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00002000

}

 

I don't know why, but the Rom is defined with only 64kB ( 0x10000 = 65536 Byte )

And now the Problem was, that I can remove some functions and then the Programm works fine, but without the needed function.

And with the functions active in the Code, the Programm works only when the value = 0x00;

At the Output of the Compiler I see that the program is exactly 65536 Bytes in the ROM.

When I Change the 0x00 into an other value, like the i then I have the Problem.

 

I have changed the LENGTH to 0x40000 and the programm works fine.

I see there also that when I use the i the programm get a length of 65540 Bytes.

 

Thanks for the hint with the "Code Looks like the example" and "the Problem must be elsewhere".

I have checked the example and it works fine, but there all the other functions are not inside.

So I remove some functions inside my Code, and then it works fine.

 

I don't konw why there the Rom has this size, because the µC has the normal size of 256kB in Flash (ROM).

Maybe an other programmer has changed it....

 

Once more thanks for your hints, and have a nice Weekend.

 

Michael

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The project must be made for the wrong device I guess. 64K is the correct rom section size for a SAMC21E16A which is what the linker script samc21e16a_flash.ld is for.

/Lars