Over the last few weeks, I’ve been setting up Photon and playing around with it. At this point, I have been able to build firmware locally and flash it to my Photon device. I am trying out an application, which will need an array of about 4K elements, of type integer. This is taking away 16KiB of SRAM, leaving less than 4KiB for the rest of the program (program stack and Heap). I sometimes see RED flashes on Photon, and I believe I am running into memory-not-available-issue.
I have been looking into the Linker Scripts, and I see that the SRAM layout is defined in part1.ld, part2.ld and user.ld under firmware/modules/. Now that I have set the context briefly, I have the following questions.
- Where can I find the complete 128KiB SRAM internal memory map? Where exactly does the Firmware code and data sit? Which all addresses are mapped to User SRAM space?
- Can I look at increasing the User SRAM, by modifying ONLY the Linker scripts? Are there any other files that needs to be modified? How easy/difficult is that? (of course, after carefully looking at the memory footprints).
- Has anyone experienced similar issues before?
In general, I am looking at having more memory to use on Photon device. I do understand that such a huge array in my application, is something to re look at, but 20KiB looks too less for me any which way. I couldn’t find any other thread on the same topic. Please do let me know of any pointers, that can help me.
@karthikuvce, the Photon has about 80KB (or more) of free SRAM. I suspect the stats you are looking at are incorrect. @suda, any comments on this?
@peekay123 Oops! That’s strange, as I’m relying on the memory stats that show up when I compile my application, which says out of 20480 bytes.
I believe an SRAM memory map table will help understand the total available memory for the user applications.
Those are the sizes for a Core, not a Photon. What does the Web IDE identify your device as?
@bko It is identified as Photon. The device rightly shows up as “P”.
How much user SRAM is the Photon supposed to show?
Photon is 1MB flash and 120kB RAM.
You can get the total memory map if you set up the local gcc toolchain and compile locally on your own computer. I don’t know of any way to get it besides that. Do a search for arm-none-eabi-nm which is the tool that will give you all the data after you compile.
Yes. It is 128KiB RAM on the Microcontroller, but for the user applications per se, only 20KiB available is what I thought (Looking at the profiled memory details). Please correct me if I am wrong.
I did look into the .map files briefly, but I thought there might a document sort of a thing which talks about the RAM memory map in detail. I will dig into the map files.
The WICED software stack takes around 70KBytes of ram, leaving you with around 60K to start with.
My guess is that the IDE is assuming the available RAM is 20k as for the core, and hasn’t been updated for the amount of memory in the Photon, so I think you can ignore these figures. (cc: @suda)
A red flash can be from many causes, and not necessarily an indication of out of memory.
Yes that’s correct, we’re running the tools to measure memory use, but the IDE still thinks everything is a core when it comes to free ram. I’ll make sure there is an open bug report for this.
Wow! That’s great
Thanks a lot @mdma @Dave for the clarification. 60KiB should be sufficient for now.
I shall anyway look into the RED flashes issue.