Hello,
My problem is as following. I have a string array, If I delete last string of GprsErrors or pointer of GprsErrors, if I make const pointer. I don't get error.
I'm using some static addresses(0x20000309, 0x20000308 .....), I guess, Keil is trying to write static address so I get the following error.
Keil shows as fgetc_b.o and constant.o overlap, I didn't find the source of the problem.
what is my fault? or How can I find and solve the problem?
Thanks alot.
Kutay,
..\Output\Project.axf: Error: L6971E: fgetc_b.o(.data) type RW incompatible with constants.o(.ARM.__AT_0x20000309) type ZI in er RW_IRAM1.
char const * GprsErrors[]={ "BAUDRATE", "AT CMD", "ATE0 CMD", "BAT INIT", "PIN CODE", ..... ".....", // I'm deleting this string and I get no error(everything is ok) };
Thanks for repply, Sorry, I didn't understand you exactly. I have write my problem as step by step.
const char pointer is const char array? That points const char data. When I added a string more, I'm thinking of change const data size but not pointer size. So why get I ram overlap error?
//===================================================
1) when I compile following code. I don't get any error (no const pointer, no string)
char const * GprsErrors[]={ "BAUDRATE", "AT CMD", "ATE0 CMD", "BAT INIT", "PIN CODE", };
//=================================================== 2) when I compile following code. I get as following error (no const pointer but just added a string)
char const * GprsErrors[]={ "BAUDRATE", "AT CMD", "ATE0 CMD", "BAT INIT", "PIN CODE", "IMEI OK", // I added this string };
//=================================================== 3) when I compile following code. I don't get any error again( added const pointer and string)
char const * const GprsErrors[]={ "BAUDRATE", "AT CMD", "ATE0 CMD", "BAT INIT", "PIN CODE", "IMEI OK", // I added this string };
And I'm using stm32. I have used about 30KB RAM but there is still free 10KB ram.
OK - I didn't realized you talked about deleting a string in the editor before rebuilding.
That extra "const" changes which memory region that will be used for the data. Const data can be stored in flash, while non-const initialized data needs a copy in flash that will then be copied into RW memory to allow you to modify the data during runtime. And the RW data + ZI (zero-initialized) data must fit into the available RAM you have configured for the processor.
Not sure what your project looks like when it comes to memory regions, but maybe you overflow the available RAM regions with your data. The extra 'const', means less data to store into RAM.
I'm using some static addresses(0x20000309, 0x20000308 .....)
Why are you doing that? You have some AT directive somewhere in your code or scatter file, which conveniently isn't shown?
Perhaps the problem is that when you add more data to the table the data expands, and now your rigid AT definitions overlay data that has already been committed to memory, and the linker complains. Suggest you remove them, and look at the .MAP file to see where the memory is now used on your bigger table.
If the strings are fixed, consider if "static const" would commit them to ROM/FLASH
AT directives should really be used as little as possible. They are there for solving very special problems - and being for advanced programming, they also tends to bite.
Thanks for replies.
I found the problem, IRAM1 and IRAM2 values had defined as false.(old micro 128Kb rom, 32kb ram) Current Microcontroller is stm32l151 series, there is 48kb ram,
False values IRAM1=0x6800 IRAM2=0x0800 (for bootloader)
IRAM1 and IRAM2 should have been 0xC000 totally
Dear Westonsupermare Pier,
I have to use static addresses because old devices had defined static for remote reading. So I can't change them.
//============================================================================================
I have another question about for remote accsess(RF/gsm etc) registers of microcontroller, I use packed structs which have dinamic address. when I access micro registers, I send struct Id and struct member ID.
what about you? what is best method for you?
First off - try to avoid playing debugger, i.e. try to avoid raw memory addresses used externally.
Next thing - if you really need to, you should build a table of indices. So just store a single pointer to this table at a known, and well selected, address - possibly first or last in RAM or last in flash.
Then use this pointer to access the table of addresses to important data structures you want to be able to remotely retrieve.
But do not (!) do make this into a two-way interface. If you really need to control something in your embedded device, then you really should send _commands_ to it. Only then will your program be able to decide on the best time to perform the commands. You might like to pick up newpaper, letters, ... from the mailbox. But you wouldn't much like if unknown people walked into your home and placed mail or boxes on a table or the floor somewhere just because they had the access and felt that gave them the right...
In the end, raw accesses are really problematic and something to avoid like the plague.
Sorry again, but the problem still didn't solve. I'm some impatient
I have defined ram sectios as following IRAM1=0xB000 IRAM2=0x0800 (for bootloader)
My compiler results ( with const pointer)
Program Size: Code=89900 RO-data=12144 RW-data=448 ZI-data=26176
I have made rebuild but I get the same error.
when I didn't find the problem, I don't trust that project.
I'm using AT commands but const data all of them, just pointer isn't const and I get error.
while const strings increase, as if pointer size increases
If you continue to place variables at fixed addresses, then you will also have to live with the problems that introduces. Unlucky designs are gifts that continues to give...
Dear Per Westermark, thanks a lot for your valuable comments.
You're right. I'm also agree. I don't want to use static addresses and I haven't used them before but now I have to use because I have been working for three months for new company.
So all of older devices(by older embedded engineers) had designed at fixed addresses and new devices should support older devices. There are 250K older devices.
What can I do? As an engineer, I'm trying to find a solution.
And there is an interesting case.I usually level 3 optimization for my projects. Older engineers hadn't used any optimization (namely optimization level 0). while optimization level 1, devices don't work. :)
I think I have to work a lot
Note that you can use a scatter file, allowing you to create custom groups for variables from different modules. Then you can make sure that the linker finds a solution where it doesn't overlap variables with the absolutely positioned variables.
With no custom configuration, the linker will think it's ok to use all the RAM - and then you or the linker will be unhappy when you add enough variables that you get overlapping.
Another thing to consider is that the profit/value of the company depends on the quality of the code. So it might be a reason to try to ask for some time allocated to code architecture work - but it requires that the company management must be convinced that it represents a profitable investment.
Most code bases requires a not too insignificant percent of the time on rework to better adapt the code to slowly changing requirements or to take advantage of new knowledge or tool improvements. It just isn't competitive to design the same way today as 10 years ago.
Carve out a region for the static stuff in the scatter file, say 0x20000000..0x200003FF, and put your new stuff elsewhere.
You'd have to look at how exactly the other data is accessed via address from outside. If it is through an interface you provide, then couldn't you just decode that appropriately?
Here we use a more considered command/response system to access internal parameters, not absolute addresses within our firmware or RAM footprint.
I have decoded, access via fixed address from outside by RF or gprs.
I will try to solve by scatter file,
Thanks a lot
But your processor is unlikely to have dual-port memory. So it's unlikely that some outside hardware can use a direct pointer to access the memory.
So exactly how is that outside access performed?