Devo7E beta15 + Switch Mod will not fit in ROM

More
26 Nov 2013 18:31 #15869 by kreidler
Just tried to compile the beta 15 with the three way switch mod without success. The build is 52 bytes too big.

How can we reduce the size of the dfu to fit in memory. I am not so deep in this source that I would know what to do. But in general, I do not need e.g. the telemetry stuff. Would it be possible to set a clause to exclude the whole telemetry source? Or is there any other possibility?

Please Log in or Create an account to join the conversation.

More
26 Nov 2013 19:36 #15875 by victzh
One way is to move RF chip drivers into modules as well, as only one of them - serving the current protocol - is active at a time.

I don't know how modules are organized, but as PhracturedBlue returned (even if in limited time to spend) we can get a clarification in the subject.

Please Log in or Create an account to join the conversation.

More
26 Nov 2013 20:20 #15877 by kreidler
Replied by kreidler on topic Devo7E beta15 + Switch Mod will not fit in ROM
victzh, thanks for the proposal but I assume that this way will cause a lot of work.

Personally telemetry is only a nice to have in a Devo7E with origin limited range and I would never use it due to lack of telemetry components from Devo or Spektrum. On my Multiplex Tx I use the telemetry for most of my projects in different ways.

So, I just started to comment some lines out with the result that I removed the telemetry section successfully. Build was ok. Afterwards I removed the comments from the permanent timer exclusions and the build was still ok. This Timer is for me a better nice to have :) .

@rbe: Could you think about two definitions enabling or disabling telemetry and permanent timer e.g. in the target_defs.h. I feel that I might be not the only guy without telemetry ambitions for that Tx. So, your commit eb9cbda could be changed to "PERMANENT_TIMER" and for the telemetry you know better than me where to add the clauses.

Please Log in or Create an account to join the conversation.

More
26 Nov 2013 21:11 #15878 by PhracturedBlue
Replied by PhracturedBlue on topic Devo7E beta15 + Switch Mod will not fit in ROM
I thought I already had one for the telemetry, but I guess not. It is certainly a reasonable request.
There isn't a lot more stuff that can be added as a module. we are limited by the size of a module (currently 4096 bytes). Making the module bigger cuts into available RAM, and we have some that are very close to max-sized already.
Since we can't unload a module (your model would fall out of the sky) you can't really modularize anything other than the protocols.

Another option would be to replace the bootloader.
It may be possible to get up to 2kb back if we used a smaller bootloader, though I'm not sure it is possible to enable USB in so little code. You would definitely lose the display during programming, and it would be pretty risky (since a program failure would result in a bricked Tx). Anyhow, the Devo7e is probably getting pretty close to the end of its development range. I'm just not sure how to squeeze much more out of it.

We could also remove the standard GUI which would save quite a bit of space, but I'm sure a lot of folks still use it. Not really my preferred solution. I don't think it helps much to remove the advanced GUI, since the standard one uses quite a bit more ROM than the advanced if I recall, so having a 'standard' build and an 'advanced' build is probably not going to help much.

Please Log in or Create an account to join the conversation.

More
26 Nov 2013 23:46 #15883 by HappyHarry
Replied by HappyHarry on topic Devo7E beta15 + Switch Mod will not fit in ROM
How about pulling all in needed languages?

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 00:20 - 27 Nov 2013 00:22 #15884 by blackmoon
Replied by blackmoon on topic Devo7E beta15 + Switch Mod will not fit in ROM

kreidler wrote: @rbe: Could you think about two definitions enabling or disabling telemetry and permanent timer e.g. in the target_defs.h. I feel that I might be not the only guy without telemetry ambitions for that Tx. So, your commit eb9cbda could be changed to "PERMANENT_TIMER" and for the telemetry you know better than me where to add the clauses.


Yes a compile switch to get rid of telemetry would be nice, I could care less for the models in use with the devo7e.

But the 3way switch I do need.

Thx

Btw nice to see you back PB :D
Last edit: 27 Nov 2013 00:22 by blackmoon.

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 02:26 #15886 by PhracturedBlue
Replied by PhracturedBlue on topic Devo7E beta15 + Switch Mod will not fit in ROM

HappyHarry wrote: How about pulling all in needed languages?

Language support was removed long ago.
I have looked for a way to compile a specific language into Deviation so that you could do:
make LANGUAGE=tw TARGET=devo7e

and have a couple ideas but so far none have panned out. I had thought to define the _tr and _tr_noop macros to replace the string but I never found a suitable solution. An alternative is to hack the source-code before compiling it, but making that robust would also take some time, and it is a very ugly solution. The 3rd possibility I came up with was to hack the object files before linking. I didn't investigate whether that is even possible; it depends on how the compiler treats static strings

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 02:59 - 27 Nov 2013 03:01 #15887 by SadSack
OpenBLT does use shade under 8k with usb.
Last edit: 27 Nov 2013 03:01 by SadSack.

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 04:15 #15888 by victzh
Can _tr be 'sed'ed into code, loading strings on demand from filesystem?

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 04:19 #15889 by victzh
In general, it all reminds me overlay managers from Fortran times when large programs managed to run in 32K, OS including ;-) And serving 12 people in Time Sharing system!

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 04:50 #15891 by PhracturedBlue
Replied by PhracturedBlue on topic Devo7E beta15 + Switch Mod will not fit in ROM

victzh wrote: Can _tr be 'sed'ed into code, loading strings on demand from filesystem?

You can't modify the binary after linking because the length of the string is different for each language so packing would get broken.
You don't want to access strings from SPI directly because (a) it is REALLY slow, and (b) we pass around string pointers everywhere which makes this hard.
You can try to fix (b) by allocating RAM for a string and copying from the filesystem when needed, but you can't know when a string is not in use and so clearing the cache becomes tricky which starts adding code again. Alternatively you could try a memory-mapped file, but this is a bit tricky to do via SPI on an STM32, and again, it would be really slow.

By far the easiest solution is to ensure the strings are swapped in the code before the linking is done, but I never put enough work into it to make it work.

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 04:56 #15892 by victzh
I finally got to the state when my SLT does not fit Devo7E beta15 as well. Or I think it is - the linker says:

target/devo7e/protocol.ld:18 cannot move location counter backwards (from 20004870 to 2000486c)
make: *** [objs/devo7e/slt_nrf24l01.bin] Error 1

This is it, right?

What about second tier of RF-chip modules? There are 4 of them now and only one is used. Will it take enormous amount of RAM? And how in general to check how much memory a module (its .o file?) takes?

I am seriously thinking of replacing the STM32 chip on my Devo7E, but it will not solve the problem for everybody else ;-)

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 05:22 - 27 Nov 2013 05:26 #15896 by PhracturedBlue
Replied by PhracturedBlue on topic Devo7E beta15 + Switch Mod will not fit in ROM
so yes, your SLT driver is now bigger than 4kb.
I think you can increase the size of the module (you need to increase the size of all of them though, and going over 4096 means they will all take up 8192bytes in Flash (due to the page size)
To do so, you need to change the devo7e.ld, devo7e_opt.ld and protocol.ld files appropriately (reduce the ram in devo7e and increase the size in protocol.ld). you also need to change the loader code to load a larger size module.
You should check how much RAM 'make' says you have on the main build. You will be taking away from that (and you need to leave some free for stack operations).

Other options are to further optimize the code to try to squeeze down the size. I do this in the dsm code by storing initialization in an array and executing it in a loop, which is cheaper than a large number of function calls, for instance.

I'm not sure what you mean by 'second tier rf modules'.

I don't recall how I figured out the size of a module...It has been a while since I last did it. I think you can use 'objdump' on the .o file and look for the last address used (note that you need room for code and static RAM allocation, but not stack)
Or you can increase the size of the module in protocol.ld until it compiles, and then check the map file (I think we make one). Again the bin file won't be sufficient because it doesn't include the RAM allocation

Again, I'm pretty rusty at this after so many months off.
Last edit: 27 Nov 2013 05:26 by PhracturedBlue.

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 05:30 #15898 by victzh
Can I manipulate by only 4K pieces? Can I make protocol memory 6K?

By second tier I mean that the protocol module uses only one RF-chip, so code handling the chip can be moved into module by it's own. But it reduces RAM even more, so there is this constraint as well.

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 06:02 #15900 by PhracturedBlue
Replied by PhracturedBlue on topic Devo7E beta15 + Switch Mod will not fit in ROM
yes you should be able to change the size to 5k or 6k (but the space on spi flash will still be 8k per module).

The problem with having 2 modules (besides being a pain to maintain all the pointers) is that you are trading off ROM (scarce) for RAM (even more scarce). The modules must be run from RAM so every time you move code into the filesystem, that code will need to be loaded into RAM before it can be used.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
27 Nov 2013 06:30 #15902 by rbe2012

victzh wrote: I finally got to the state when my SLT does not fit Devo7E beta15 as well. Or I think it is - the linker says:

target/devo7e/protocol.ld:18 cannot move location counter backwards (from 20004870 to 2000486c)
make: *** [objs/devo7e/slt_nrf24l01.bin] Error 1

I ran into exactly this error (with wk2x01) yesterday. It resulted from assigning a value to a variable outside of the functions so the data section was used. I moved the assignment in the appropriate function and nothing happened anymore.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
27 Nov 2013 06:35 #15903 by rbe2012
Maybe I could try to integrate the switch mod into the default code. I will see how much space I can gain elsewhere.
We can comment it out (via target_defs) but make sure that we keep the space free.
@kreidler: since you have done already, can you tell me where you disabled the telemetry? I will add switches for telemetry and the permanent timer setting (and the switch mod) so you could choose.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
27 Nov 2013 06:36 #15904 by rbe2012

PhracturedBlue wrote: I had thought to define the _tr and _tr_noop macros to replace the string but I never found a suitable solution. An alternative is to hack the source-code before compiling it, but making that robust would also take some time, and it is a very ugly solution.

I also thought about that but however you do it, you have to change the source files - that means, it can only done once or you have to take a fresh copy every time. And you can run into space problems as with every other code change.
Maybe I should play a while...

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
27 Nov 2013 07:27 #15909 by rbe2012

rbe2012 wrote: Maybe I could try to integrate the switch mod into the default code. I will see how much space I can gain elsewhere.

No need for gaining space - fits without changes.
Maybe I have the wrong version: I tried the one from PB here
and also this one from kaworu .
Can anyone point me to the correct version or send me a patch?

Please Log in or Create an account to join the conversation.

More
27 Nov 2013 07:31 #15910 by victzh
Thanks, it may be it, because the module did not change substantially, but I changed something.

How did you find what you did exactly?

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum