Author Topic: Does This Mean I'm Out of Device Memory  (Read 2885 times)

0 Members and 1 Guest are viewing this topic.

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Does This Mean I'm Out of Device Memory
« on: October 30, 2022, 10:14:10 pm »
I have a project the compiles fine on a machine running MPLABX 5, but on another machine running MPLABX v6 I get the following when trying to compile:

build/default/production/main.o: Link Error: Could not allocate section .text, size = 6400 PC units, attributes = code
build/default/production/main.o: Link Error: Could not allocate section .const, size = 856 PC units, attributes = psv page
build/default/production/mcc_generated_files/I2C_EEPROMDrivers/i2c_eeprom_app.o: Link Error: Could not allocate section .text, size = 626 PC units, attributes = code
build/default/production/LCD_8bit.o: Link Error: Could not allocate section .text, size = 448 PC units, attributes = code
data_init: Link Error: Could not allocate section .dinit, size = 396 PC units, attributes = code keep
build/default/production/mcc_generated_files/i2c1.o: Link Error: Could not allocate section .text, size = 234 PC units, attributes = code
build/default/production/mcc_generated_files/i2c2.o: Link Error: Could not allocate section .text, size = 234 PC units, attributes = code
build/default/production/mcc_generated_files/spi1.o: Link Error: Could not allocate section .text, size = 190 PC units, attributes = code
build/default/production/mcc_generated_files/tmr2.o: Link Error: Could not allocate section .text, size = 110 PC units, attributes = code
build/default/production/mcc_generated_files/uart2.o: Link Error: Could not allocate section .text, size = 90 PC units, attributes = code
build/default/production/mcc_generated_files/tmr1.o: Link Error: Could not allocate section .text, size = 88 PC units, attributes = code
build/default/production/mcc_generated_files/tmr5.o: Link Error: Could not allocate section .text, size = 88 PC units, attributes = code
build/default/production/mcc_generated_files/tmr3.o: Link Error: Could not allocate section .text, size = 86 PC units, attributes = code
build/default/production/mcc_generated_files/interrupt_manager.o: Link Error: Could not allocate section .text, size = 72 PC units, attributes = code
build/default/production/mcc_generated_files/pin_manager.o: Link Error: Could not allocate section .text, size = 64 PC units, attributes = code
build/default/production/mcc_generated_files/clock.o: Link Error: Could not allocate section .text, size = 46 PC units, attributes = code
delay32.Meo: Link Error: Could not allocate section .init.delay32, size = 28 PC units, attributes = code
build/default/production/mcc_generated_files/system.o: Link Error: Could not allocate section .text, size = 24 PC units, attributes = code
build/default/production/mcc_generated_files/traps.o: Link Error: Could not allocate section .text, size = 14 PC units, attributes = code
build/default/production/LCD_8bit.o: Link Error: Could not allocate section .const, size = 12 PC units, attributes = psv page
build/default/production/mcc_generated_files/system.o: Link Error: Could not allocate section .text, size = 24 PC units, attributes = code
build/default/production/mcc_generated_files/traps.o: Link Error: Could not allocate section .text, size = 14 PC units, attributes = code
build/default/production/LCD_8bit.o: Link Error: Could not allocate section .const, size = 12 PC units, attributes = psv page
 Link Error: Could not allocate program memory
make[2]: *** [nbproject/Makefile-default.mk:327: dist/default/production/Water_Monitor_UI_New_Comm.X.production.hex] Error 255
make[1]: *** [nbproject/Makefile-default.mk:91: .build-conf] Error 2
make: *** [nbproject/Makefile-impl.mk:39: .build-impl] Error 2

BUILD FAILED (exit value 2, total time: 852ms)


On the machine that compiles successfully I am using optimization level 1 and the compiled code consumes 92% of available program memory and about half of available data memory.  The device I'm trying to compile to is a PIC24FV32KA302.  I'm using the same project properties on both machines.
« Last Edit: October 30, 2022, 10:40:11 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13853
  • Country: gb
    • Mike's Electric Stuff
Re: Does This Mean I'm Out of Device Memory
« Reply #1 on: October 30, 2022, 10:51:56 pm »
This sort of issue should be a function of compiler  version, not the MPLABX version. You can have multiple compilers installed, so you should be able to compile under the previous compiler within MPLABX 6 if you have the older compiler installed.

Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #2 on: October 31, 2022, 12:01:06 am »
This sort of issue should be a function of compiler  version, not the MPLABX version. You can have multiple compilers installed, so you should be able to compile under the previous compiler within MPLABX 6 if you have the older compiler installed.

I was afraid of that.  The older XC16 compilers available in the Microchip archive are indicated as Source Archives and I'm not sure how to get the version I need registered in MPLABX for Mac OS.

The source archives appear to be literally source code for the XC16 compiler.  Not sure how to compile into something useful to MPLABX.
« Last Edit: October 31, 2022, 12:09:52 am by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1314
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #3 on: October 31, 2022, 01:00:58 am »
Are they both using the same C language mode?...C90 vs C99.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6093
  • Country: es
Re: Does This Mean I'm Out of Device Memory
« Reply #4 on: October 31, 2022, 01:19:07 am »
Yep. Open project settings, go to compiler optimizations and enable O2 (free) or Os(Pro).
That's probably the culprit.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 841
Re: Does This Mean I'm Out of Device Memory
« Reply #5 on: October 31, 2022, 01:27:03 am »
Quote
The older XC16 compilers available in the Microchip archive are indicated as Source Archives and I'm not sure how to get the version I need

https://www.microchip.com/en-us/tools-resources/archives/mplab-ecosystem

Language Tools Archives, they have every version of XC16 available from v1.00, 5/3/12 and you may have to 'scroll' right 1..15 to find what you want.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #6 on: October 31, 2022, 02:47:38 am »
Quote
The older XC16 compilers available in the Microchip archive are indicated as Source Archives and I'm not sure how to get the version I need

https://www.microchip.com/en-us/tools-resources/archives/mplab-ecosystem

Language Tools Archives, they have every version of XC16 available from v1.00, 5/3/12 and you may have to 'scroll' right 1..15 to find what you want.

Well, it almost worked.  I downloaded, installed and tried to compile, but it failed on bad CPU type.  My new Mac has M1 CPU.  Thanks for the link though.  It looks like I'll just need to hang on to the old Mac for a while.
« Last Edit: October 31, 2022, 02:55:10 am by Ground_Loop »
There's no point getting old if you don't have stories.
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3490
  • Country: it
Re: Does This Mean I'm Out of Device Memory
« Reply #7 on: October 31, 2022, 06:21:17 am »
XC16 2.0 doesn't work as well as previous versions, internal changes added unnecessary bloat (the compiler forgot that it can do indirect addressing with an offset, and instead calculates the actual address every time. all pointers, including arrays, are affected)
Confirmed bug, still waiting for 2.10 to be released but they already skipped two release cycles this year.

I don't remember if 1.70 can work on Apple M1, i fear not, in which case tough luck.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #8 on: October 31, 2022, 11:22:57 am »
I've tried O2 optimization to no avail.  I get the same results.  Anyway this is just a hobby for me and my older laptop still works, so for this particular project I'll just use the old one.  And I'm not moving up to a paid license.  uCs with more memory are not available in the series either.   Thanks all for the responses.
There's no point getting old if you don't have stories.
 

Offline woofy

  • Frequent Contributor
  • **
  • Posts: 348
  • Country: gb
    • Woofys Place
Re: Does This Mean I'm Out of Device Memory
« Reply #9 on: October 31, 2022, 11:54:02 am »
It was a hard lesson to learn, but I now include MPLABX and XC versions in the projects documentation.

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 841
Re: Does This Mean I'm Out of Device Memory
« Reply #10 on: October 31, 2022, 12:03:21 pm »
Quote
And I'm not moving up to a paid license
This still works-
https://github.com/cv007/XC3216/blob/master/xc32xc16-info.txt
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3490
  • Country: it
Re: Does This Mean I'm Out of Device Memory
« Reply #11 on: October 31, 2022, 12:31:01 pm »
I've tried O2 optimization to no avail.  I get the same results.  Anyway this is just a hobby for me and my older laptop still works, so for this particular project I'll just use the old one.  And I'm not moving up to a paid license.  uCs with more memory are not available in the series either.   Thanks all for the responses.

The problem in 2.00 is NOT in optimization, but in code generation.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #12 on: October 31, 2022, 12:38:05 pm »
I've tried O2 optimization to no avail.  I get the same results.  Anyway this is just a hobby for me and my older laptop still works, so for this particular project I'll just use the old one.  And I'm not moving up to a paid license.  uCs with more memory are not available in the series either.   Thanks all for the responses.

The problem in 2.00 is NOT in optimization, but in code generation.

Understood, but an earlier post suggestion was to try O2.
There's no point getting old if you don't have stories.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6093
  • Country: es
Re: Does This Mean I'm Out of Device Memory
« Reply #13 on: October 31, 2022, 01:38:46 pm »
That's strange. If you used the same code in different compilers, the difference should be negligible.
If you used a different library, that's a completely different thing, stay with the same library version you were using ealier!
You can download any pack version under Tools/Packs...
Then open the project settings and choose which pack to use.
Better stay with v5.50, I tried v6.00 and had several issues.
Also try this.
If it's DIY, I can try to help if you send me the project.

About the O2 optimization. What you were using in MPLABX 5? Perhabs you werte running Os (Optimize for size).
In any case, the IDE won't change a thing in the code, that's entirely up to the compiler.

I'll tell you something you've heard a million times: If not broken, don't fix it!
Was wokring in v5? Then stay with v5 and enjoy :-DD
« Last Edit: October 31, 2022, 01:46:33 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3490
  • Country: it
Re: Does This Mean I'm Out of Device Memory
« Reply #14 on: October 31, 2022, 01:54:32 pm »
Again, V2.00 has a problem in CODE GENERATION, not optimization.
the microchip 16bit architecture can deference a pointer with offset in a single instruction.
Pointer with offset can be a member of a pointer to struct, or when you pass an array to a function, because you pass the address of the first element and the compiler can't use the literal address.

Instead of using a single instruction the compiler uses two or three. see my thread over at the microchip forum where i posted code and generated assembly comparing all optimization levels.
https://www.microchip.com/forums/m1198055.aspx

FWIW, there could be other issues such as the new libc because the compiler is finally (hah) fully C99 compliant and there could be a bigger library. Also you may need to change the code and memory models, but usually they get carried over when you change compiler versions.. and with 32k flash you can't use large code model anyway. but the code generation problem was the bigger one for me, in the project i tested it it increase code size to about 15%. That's a lot, and i can't find a reason the compiler team didn't catch it, especially because (and i have to repeat it again because too many already blabbered about optimization levels) IT AFFECTS EVERY OPTIMIZATION LEVEL
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #15 on: October 31, 2022, 02:02:53 pm »
That's strange. If you used the same code in different compilers, the difference should be negligible.
If you used a different library, that's a completely different thing, stay with the same library version you were using ealier!
You can download any pack version under Tools/Packs...
Then open the project settings and choose which pack to use.
Better stay with v5.50, I tried v6.00 and had several issues.
Also try this.
If it's DIY, I can try to help if you send me the project.

About the O2 optimization. What you were using in MPLABX 5? Perhabs you werte running Os (Optimize for size).
In any case, the IDE won't change a thing in the code, that's entirely up to the compiler.

I'll tell you something you've heard a million times: If not broken, don't fix it!
Was wokring in v5? Then stay with v5 and enjoy :-DD

Same library, same toolpak.  I've been through all the permutations.  I'm going with Portici's explanation.  Anyway, this M1 chip is a real headache, and for more than just uC stuff.
There's no point getting old if you don't have stories.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6093
  • Country: es
Re: Does This Mean I'm Out of Device Memory
« Reply #16 on: October 31, 2022, 02:12:11 pm »
It worked nice before, you broke it when updating the compiler to v2.00... so simply use v1.70?
Otherwise what's the logic on using v2.00 just because it's newer (But breaks everything)? :-//
Seems like a simple fix to me!
« Last Edit: October 31, 2022, 02:17:31 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #17 on: October 31, 2022, 04:43:06 pm »
I didn't break anything. I have a new laptop that is not compatible with the older versions and apparently some newer versions. Other than this one case it works just fine. The 12 year old laptop is still functional, so if required I'll use that one.  Not sure how that point was not clear up until now.
« Last Edit: October 31, 2022, 04:45:20 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #18 on: November 23, 2022, 08:20:32 pm »
Solved it...sort of.

I found another micro with nearly identical peripheral set, pinout, and four times the memory in the same package.  Odd though that one of the IO bits--PORTAbits.RA4--had no definition in the header file.  I sorted that out and added it myself, so all good.  The down side is that the new device is 3.3V instead of 5V, but that can be worked with.  Otherwise, the original code compiles fine with all the latest soft/firmware revs.
« Last Edit: November 23, 2022, 08:25:30 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3294
  • Country: gb
Re: Does This Mean I'm Out of Device Memory
« Reply #19 on: November 24, 2022, 09:50:24 am »
Have you tried running the older tools through Wine?  It has supported running x86 executables on Arm based MACs for a while.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 661
  • Country: us
Re: Does This Mean I'm Out of Device Memory
« Reply #20 on: November 24, 2022, 11:51:38 am »
Have you tried running the older tools through Wine?  It has supported running x86 executables on Arm based MACs for a while.

I'm trying to stay away from Windows tools on this machine.  So far, everything I need is working.  If I really need to use Windows for something I have several other machines.
There's no point getting old if you don't have stories.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf