another i2c / xmmc question
Mark Mara
Posts: 64
I need some more help. I am working on a project using xmmc. I have been using the cog_c_toggle demo code as my model. I can open an i2c bus using i2cBootOpen() in the main routine with no problems, however, if I start a cog and try to the do the i2cBootOpen() from there I get an error message.
I can demonstrate my problem using the cog_c_toggle demo code. If I put a i2cBootOpen() in toggle.c it works fine if I put the i2cBootOpen() in toggle_fw.c I get this:
Any help would be greatly appreciated.
I can demonstrate my problem using the cog_c_toggle demo code. If I put a i2cBootOpen() in toggle.c it works fine if I put the i2cBootOpen() in toggle_fw.c I get this:
bottomshotserver:my_toggle_2 mam1$ make clean rm -f *.o *.elf *.a *.cog *.ecog *.binary bottomshotserver:my_toggle_2 mam1$ make MODEL=xmmc BOARD=c3 propeller-elf-gcc -Os -mxmmc -o toggle.o -c toggle.c propeller-elf-gcc -Os -mcog -r -o toggle_fw.cog toggle_fw.c propeller-elf-objcopy --localize-text --rename-section .text=toggle_fw.cog toggle_fw.cog propeller-elf-gcc -Os -mxmmc -fno-exceptions -fno-rtti -o toggle.elf toggle.o toggle_fw.cog toggle_fw.cog: In function `_main': :(toggle_fw.cog+0x54): relocation truncated to fit: R_PROPELLER_SRC against symbol `_i2cBootOpen' defined in .text section in /opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/xmmc/libc.a(cogload.o) collect2: ld returned 1 exit status make: *** [toggle.elf] Error 1 bottomshotserver:my_toggle_2 mam1$
Any help would be greatly appreciated.
Comments
Any time you see "relocation truncated to fit" it means your program has grown beyond the limits of the memory model.
If you need i2c access in a COG sized program you have a few choices.
1. Add some code to the COG C file usually via copy paste so you know the stack won't blow up.
2. Use a mailbox handler in a CMM/LMM/XMM* main program that can provide services.
There may be more, but these are obvious to me.
Normally when working with CMM or LMM I see something like
In your case I don't see the amount of overflow bytes.
I used these flags without understanding what they do. Could you point me at any documentation? I clearly need a better understanding of what is happening.
I believe that jazzed is telling me that size of the i2c routines are such that I can not fit them into a cog so the only way to run them is from the main program. Is this correct?
https://code.google.com/p/propgcc/source/browse/lib/include/i2c.h
https://code.google.com/p/propgcc/source/browse/lib/include/i2c_driver.h