Does teensyduino support ARM scatter loading?

wearyhacker

Well-known member
The question is in the title.

I have a sketch I am trying to link and upload under platformio using a GNU gcc toolchain. The sketch uses the ArduinoMenu and the Teensy Audio libraries. Building a version of the sketch that only uses one of the two libraries works perfectly. Build with both linked in crashes on upload and needs a full reset of the teensy to get usb conectivity back.

Examining the elf output of the full sketch show that it has a .ARM.exidx (scatter loading) section present that is not present in the working sketches.

This section might be a result of corruption of the ELF file by overflow etc., or it might be valid.

My knowledge of ARM scatter loading is zero!

If the answer to the actual question is yes. Then any further suggestions will be gratefully received.

Roger
 
The Teensy Loader has ' Help / Verbose info' that gives upload feedback that might indicate the timing and nature of the problem.
> Suggest perhaps: open that verbose and Clear it. Upload the working case and set that output aside. Clear verbose and upload the fail case and capture and compare the upload verbose output.

Platformio introduces user to user build variability and isn't easily repro by forum members. Building under Arduino IDE presents uniform console output and tool usage to observe that output for common issues and feedback.

Any chance it could be built under the IDE for the working then the non working cases to see/show if warnings or errors are presented during the build?
 
To try to answer your question I had to first Google search "ARM scatter loading", because that's a phase that hasn't really come up over all these years of Teensy. This seems to be the relevant info:

https://developer.arm.com/documenta...eatures/the-scatter-loading-mechanism?lang=en

The simplest answer I can give you is this: No, but maybe kinda yes, but probably not really.

As nearly as I can tell, from an admittedly very quick glance at ARM's documentation, "scatter loading" seems to be a feature of ARM's proprietary compiler. We've never used ARM's proprietary compiler for any Teensy products. So specifically regarding "scatter loading", the answer to your question is a hard No, since we've never used the software with that specific named feature.

The maybe kinda yes answer is that we definitely do use the linker script feature of the gcc toolchain. The syntax is completely different (again, caveat that I only quickly glanced at ARM's documentation, and I'm not even 100% sure that page Google found is the same thing you're asking about) but it has some similarities.

But the way we make use of the linker script for Teensy 4.x is somewhat unconventional, which is the but probably not really part of my answer. Just a couple days ago I wrote a lengthy message on a conversation from a guy who really takes exception to this. Here's that thread. Skip to msg #4 if you like.

https://forum.pjrc.com/threads/73240-Teensy-4-1-linker-script-is-really-wrong

Maybe I missed details in my quick look at ARM's documentation (just for the sake of answering your question) but I didn't see the sort of very flexible features we use in Teensy 4's linker scripts.

Whether that's even relevant for you, I don't know. You did say you have "platformio using a GNU gcc toolchain" at the beginning of your question. So why you would ask about a feature that's specific to a different toolchain is pretty confusing (at least to me). But I've tried to answer anyway.



Now if I could answer with another question, does your program work if you compile and upload with Arduino IDE?

As Defragster mentioned, we hear a lot of strange problems with PlatformIO on this forum, because people use build settings different than the officially supported way Arduino IDE compiles. Officially PJRC really only supports use of Arduino IDE. Maybe people do use PlatformIO. But it lets you change almost anything about the build process. The farther you stray from the build process we use with Arduino IDE, which is how all the library code is tested, the more likely you are to have strange problems that are quite difficult.
 
Thanks defragster and Paul for your responses. Especially since I broke just about every rule in the forum about asking questions without full backing information.

My gut feel about about this is that it is nothing to do with scatter loading and that the firmware.elf file that is being generated is corrupt.

If I switch from the gui XELFViewer to good old command line readelf. I do get and number of warnings output.

Code:
readelf: Warning: corrupt index table entry: 8101b108
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8400b0b0
readelf: Warning: Could not locate .ARM.extab section containing 0x1f6dc8.
readelf: Warning: Could not locate .ARM.extab section containing 0x80369c7.
readelf: Warning: Could not locate .ARM.extab section containing 0x1986d5c.
readelf: Warning: Could not locate .ARM.extab section containing 0xc0369df.
readelf: Warning: Could not locate .ARM.extab section containing 0x4f6e28.
readelf: Warning: corrupt index table entry: 8400b0b0
readelf: Warning: Could not locate .ARM.extab section containing 0xb272a9.
readelf: Warning: corrupt index table entry: 8400b0b0
readelf: Warning: Could not locate .ARM.extab section containing 0x1419c8.
readelf: Warning: Could not locate .ARM.extab section containing 0x7858830.
readelf: Warning: Could not locate .ARM.extab section containing 0x10af82c.
readelf: Warning: Could not locate .ARM.extab section containing 0xb21af0.
readelf: Warning: Could not locate .ARM.extab section containing 0x8076c4c.
readelf: Warning: corrupt index table entry: 8101b108
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8400b0b0
readelf: Warning: Could not locate .ARM.extab section containing 0x319c90.
readelf: Warning: corrupt index table entry: a4046c00
readelf: Warning: Could not locate .ARM.extab section containing 0x2e776d81.
readelf: Warning: Corrupt ARM compact model table entry: ffff40c0 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Could not locate .ARM.extab section containing 0x1016c90.
readelf: Warning: Could not locate .ARM.extab section containing 0x8036aa7.
readelf: Warning: Could not locate .ARM.extab section containing 0x3c0b9ccf.
readelf: Warning: Corrupt ARM compact model table entry: d40001cc 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8400b0b0
readelf: Warning: corrupt index table entry: 8101b108
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: b082b510 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: b082b510 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: b5b0b40f 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: b09db5f0 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80971cab
readelf: Warning: corrupt index table entry: 80acb0b0
readelf: Warning: Corrupt ARM compact model table entry: f1b06808 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8002abb0
readelf: Warning: Corrupt ARM compact model table entry: f000b508 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: b5702850 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80aab0b0
readelf: Warning: Corrupt ARM compact model table entry: b50828ff 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80b108ab
readelf: Warning: corrupt index table entry: 80028400
readelf: Warning: Corrupt ARM compact model table entry: b082b510 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8001a8b0
readelf: Warning: Corrupt ARM compact model table entry: f7ffb510 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80a8b0b0
readelf: Warning: corrupt index table entry: 80acb0b0
readelf: Warning: Corrupt ARM compact model table entry: bf004770 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80a8b0b0
readelf: Warning: Corrupt ARM compact model table entry: ba48f7fd 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8003aab0
readelf: Warning: Corrupt ARM compact model table entry: f7f9b508 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8002a9b0
readelf: Warning: corrupt index table entry: 80a8b0b0
readelf: Warning: corrupt index table entry: 80aab0b0
readelf: Warning: corrupt index table entry: 80b271ae
readelf: Warning: corrupt index table entry: 80383fab
readelf: Warning: corrupt index table entry: 80aab0b0
readelf: Warning: Corrupt ARM compact model table entry: b12268c2 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80b20daa
readelf: Warning: corrupt index table entry: 8008afb0
readelf: Warning: Corrupt ARM compact model table entry: f7ff2300 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80023fad
readelf: Warning: Corrupt ARM compact model table entry: b085b500 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 80048400
readelf: Warning: Corrupt ARM compact model table entry: bff0f7ff 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: corrupt index table entry: 8004adb0
readelf: Warning: corrupt index table entry: 8003a8b0
readelf: Warning: Corrupt ARM compact model table entry: f7ffb508 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: f7ffb508 
readelf: Warning: Unknown ARM compact model index encountered
readelf: Warning: Corrupt ARM compact model table entry: f7f6
readelf: Warning: Unknown ARM compact model index encountered
So the above seems to suggest that a corrupt elf file is being generated the 'appears' to be a scatter loading section. However if I use strings to look at the file I get the following.
Code:
roger@dragon:~/pioprojects/ctroger/.pio/build/debug$ strings firmware.elf|grep exidx
__exidx_end
__exidx_start
.ARM.exidx
One possible explanation could be that these strings are diagnostic information that is being inserted into the elf file after the main structure has been generated.

The linker that is being used in the toolchain is gnu arm-none-eabi-ld. This statement in the official documentation may shed some light on what is going on.

"Aside from its flexibility, the GNU linker is more helpful than other linkers in providing diagnostic information. Many linkers abandon execution immediately upon encountering an error; whenever possible, ld continues executing, allowing you to identify other errors (or, in some cases, to get an output file in spite of the error)."

I am going to try to force to it stop execution immediately it encounters an error, and see what I can deduce from that.

For information the upload process I use uses the Teensy GUI loader and that reports a successful upload.

Roger
 
This sounds like some of the code is relying on exception handling. I know the Arduino IDE build process disables exceptions and the linker script isn't compatible with it, so definitely seems like a PlatformIO issue.
 
I'm really confused.

and that the firmware.elf file that is being generated is corrupt.

Can you explain what software is generating a corrupt .elf file? Is this PlatformIO? Are you using the Teensy package the PlatformIO developers publish? If something else, can you at leave give us some info and context to understand what software you're actually running?

Have you tried simply using Arduino IDE with Teensyduino to build your code? If you click File > Preferences, you can turn on verbose output during compile, so Arduino IDE will show the exact gcc commands it ran to compile your code.
 
I'm really confused.
Can you explain what software is generating a corrupt .elf file? Is this PlatformIO?
As mentioned in the previous post the software generating the elf file is gnu arm-none-eabi-ld.
Are you using the Teensy package the PlatformIO developers publish?
Yes.
If something else, can you at leave give us some info and context to understand what software you're actually running?
It is a standard PlarformIO setup using the arduino framework supplied as part of the teensy platform package. This is basically a few scripts wrapped around your cores and teensyduino repositories on github.
Have you tried simply using Arduino IDE with Teensyduino to build your code? If you click File > Preferences, you can turn on verbose output during compile, so Arduino IDE will show the exact gcc commands it ran to compile your code.
No. Platformio prodvides exactly the same level of verbose ouput for the compile and upload processes.
 
Thanks for the suggestions. But please do not waste more time on this until I have had the time to try the code in the Arduino IDE.

Thanks once again for the time you have taken to help me with this.

Roger
 
Back
Top