PDA

View Full Version : Teensy ARM Memory Map and CRC Build Utility



JoeChurchwell
08-15-2018, 10:56 PM
Hello Teensy Lovers!

I created a Teensy memory map and CRC generator for the Teensy Arduino build process that will put a nicely formatted memory map in the Arduino build output (verbose compile output). Currently, it only works for Windows [ :confused: I know right?!]. I invite anyone to update/modify the source and please share your application. :cool: I am using this to work on an advanced terminal program for Teensy ARM.

Here is a link to the Git repository:
https://github.com/jchurchwell/Teensy-Memory-Map

To get setup after downloading the source code:

This assumes you have Arduino and the Teensy Arduino Add-In


Compile the VB.NET source to the release directory
Navigate to the Arduino hardware tools directory
Re-name the file 'teensy_post_compile.exe' to 'REAL_teensy_post_compile.exe'
Copy the file 'teensy_post_compile.exe' from the release directory and place it in the Arduino-hardware-tools directory
i.e. 'C:\Program Files (x86)\Arduino\hardware\tools'
Verify, through the Arduino IDE preferences (File->Preferences), that the 'Show verbose output during compile’ is checked
Test the memory map generation Using the Arduino IDE and note that it displays the memory map in the compile output window


And here is an example output:






Variable Name

Memory Address Segment : Memory Address Offset

SizeInBytes





14462

defragster
08-15-2018, 11:21 PM
Awesome for Windows! I just installed VS17 so I wanted something to build.

It did:

1>------ Build started: Project: teensy_post_compile, Configuration: Release Any CPU ------
1>T:\T_Downloads\Teensy-Memory-Map-master\Teensy-Memory-Map-master\teensy_post_compile\teensy_post_compile\tee nsy_post_compile\Module1.vb(155,43): warning BC42024: Unused local variable: 'M'.
1> teensy_post_compile -> T:\T_Downloads\Teensy-Memory-Map-master\Teensy-Memory-Map-master\teensy_post_compile\teensy_post_compile\tee nsy_post_compile\bin\Release\teensy_post_compile.e xe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

But I don't see a map - just the prior RAM/FLASH use numbers?

Did I miss something? I downloaded the Zip - and the solution was in another zip I extracted in the folder and it built.

JoeChurchwell
08-15-2018, 11:32 PM
It's cool to see someone interested so soon!

I am happy to help... Did you follow the 6 steps outlined in the README.md (also included above)?

I am using Windows 7... BTW

-Joe

defragster
08-15-2018, 11:49 PM
Win 10 here. Resultant EXE was 12KB versus REAL of 25KB.

I did my best to read and follow the steps.



-a---- 6/7/2018 4:53 PM 25600 REAL_teensy_post_compile.exe
-a---- 8/15/2018 4:12 PM 12288 teensy_post_compile.exe

OH WAIT … I'm using TyCommander - it may replace/subvert the post_compile process … loading the TeensyLoader IDE ...

Now just missing one step :: find 'avr-objdump.exe'



'avr-objdump.exe' is not recognized as an internal or external command,

operable program or batch file.

***************** CRC CALCULATIONS *******************
ELF CRC = F02561E
HEX CRC = 41DD9B45
MAP CRC = 0
**************** END CRC CALCULATIONS ****************

<edit>: I build from here :: T:\arduino_1.8.5_142\hardware\tools

JoeChurchwell
08-16-2018, 12:05 AM
Awe Snap! I think I'll have to add another step in the required steps. Try to add WinAVR to your path variable. If you don't have WinAVR then I suppose you will have to get that too. This is what is the pertinent information in my path variable: "C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin"

If you don't want to set the path variable you can change the VB program to be more explicit on where to look for avr-objdump.exe.

defragster
08-16-2018, 12:38 AM
I rebuilt to use::
shell_output = "cmd /c t:\tmp\objdump.exe -t " & output_path & "\" & output_file & ".elf" & " > " & output_path & "\" & output_file & ".map"

{from the ARM toolchain - not the AVR- version}

and copied to t:\tmp from :: "T:\arduino_1.8.5_142\hardware\tools\arm\arm-none-eabi\bin\objdump.exe"



T:\arduino_1.8.5_142\hardware\teensy/../tools/teensy_post_compile -file=DebugTest.ino -path=T:\TEMP\arduino_build_115913 -tools=T:\arduino_1.8.5_142\hardware\teensy/../tools -board=TEENSY36 -reboot -port=usb:0/140000/0/1/1 -portlabel=COM10 (Teensy 3.6) Serial -portprotocol=Teensy
__brkval 1fff:0750 4
__fdlib_version 1fff:080e 1
__global_locale 1fff:0c3c 364
__malloc_av_ 1fff:0da8 1032
__malloc_current_mallinfo 1fff:16a4 40
__malloc_max_sbrked_mem 1fff:169c 4
__malloc_max_total_mem 1fff:1698 4
__malloc_sbrk_base 1fff:11b4 4
__malloc_top_pad 1fff:16a0 4
__malloc_trim_threshold 1fff:11b0 4
__mprec_bigtens 0000:8970 40
__mprec_tens 0000:88a8 200
_ctype_ 0000:87a0 257
_Ftype 1fff:0730 28
_global_impure_ptr 0000:878c 4
_impure_ptr 1fff:0c38 4
_VectorsFlash 0000:0000 464
_VectorsRam 1fff:0200 464
_ZN11MillisTimer10listActiveE 1fff:1340 4
_ZN11MillisTimer11listWaitingE 1fff:1350 4
_ZN14EventResponder10firstYieldE 1fff:1348 4
_ZN14EventResponder13lastInterruptE 1fff:133c 4
_ZN14EventResponder14firstInterruptE 1fff:1338 4
_ZN14EventResponder16runningFromYieldE 1fff:134c 1
_ZN14EventResponder9lastYieldE 1fff:1344 4
DebBack 1fff:11d8 42
DebCnt 1fff:11d4 4
DebInfo 1fff:1208 40
DebSer 0000:8500 4
digital_pin_to_info_PGM 0000:8508 512
errno 1fff:16e0 4
flashconfigbytes 0000:0400 16
last_func 1fff:1204 4
Serial 1fff:0754 16
string0 1fff:07f4 4
systick_millis_count 1fff:1238 4
usb_buffer_memory 1fff:03d0 864
usb_cdc_line_coding 1fff:16d4 8
usb_cdc_line_rtsdtr 1fff:1334 1
usb_cdc_line_rtsdtr_millis 1fff:16dc 4
usb_cdc_transmit_flush_timer 1fff:1324 1
usb_configuration 1fff:131c 1
usb_descriptor_list 0000:8734 84
usb_endpoint_config_table 0000:8730 4
usb_reboot_timer 1fff:12a5 1
usb_rx_byte_count_data 1fff:16cc 8
usb_rx_memory_needed 1fff:1311 1
usb_string_manufacturer_name_default 1fff:0780 24
usb_string_product_name_default 1fff:07dc 22
usb_string_serial_number_default 1fff:07f8 22
***************** CRC CALCULATIONS *******************
ELF CRC = 53C0B59D
HEX CRC = 7FB23C1E
MAP CRC = C9741A17
**************** END CRC CALCULATIONS ****************

That worked quick and dirty.
To confirm the TyCommander edits to platform.txt comments out the teensy_post_compile lines.

JoeChurchwell
08-16-2018, 01:50 AM
Cool! I wonder if there is any difference between the toolchains. I'll have to try it both ways and do a diff. ;-)

defragster
08-16-2018, 02:06 AM
Hopefully the same read of the HEX (?) file gice the same results. But the ARM code should come with Teensy and always be in that spot.

If you are going to really hope to make an 'advanced terminal program for Teensy ARM' you should work with TyCommander. Koromix may or may not be looking to develop that further - I haven't had issues in some time to ask him about where he has been most responsive in past years. But that is an robust and exemplary piece of work that makes using Teensy and the IDE way more awesomer than it is without it! It does program loading as well as SerMon to one or more devices in one or more windows with a pleasing GUI. His code is on github and I believe open. He had noted ideas in past about doing more with it. His code is all 'c' and builds for him not on Windows - but there is a way to do that. TyComm reads the HEX and parses it to confirm the type of Teensy at hand - he could easily construct this DUMP on an info page.

JoeChurchwell
08-16-2018, 03:07 AM
That seems cool but a bit more complicated than what I wanted to do. Either way I'll check it out. Thanks.

defragster
08-16-2018, 04:07 AM
Paul: I added this to my TeensyDuino 1.42 IDE and I'm now seeing ::


Now able to open COM10 (Windows said this port was ready before it was actually ready...)

That prints as the building starts and after it completes:: Unable to open COM10

After the build the upload worked and the T_sermon connected just fine.


Perhaps it is to be expected if the 'teensy_post_compile.exe' program has some other code not replicated?

<edit>: removed private teensy_post_compile.exe - and behavior above goes back to normal without those notes.

defragster
08-16-2018, 04:52 AM
Scanning the code I see the problem might be :: Const TEENSY_POST_COMPILER As String = "REAL_teensy_post_compile.exe" ' "C:\Program Files (x86)\Arduino\hardware\tools\REAL_teensy_post_comp ile.exe"

That is not where my tools dir is. So it was failing to call that REAL_ exe.

JoeChurchwell
08-16-2018, 10:43 AM
Actually the "REAL_teensy_post_compiler" is a relative path. I had this hard coded to my path before and left my path in there for commenting purposes. So it is actually a relative path where the single quote, in VB, is a comment.

However, the "REAL_teensy_post_compiler.exe" file should be in the same path as the generated exe "teensy_post_compile.exe"

Does that help? The whole thing is kind of a hack 😁

JoeChurchwell
08-16-2018, 05:08 PM
Okay... I updated the Git repository to find the objdump.exe file using a directory recursive search. This will try to find the ARM version and if it can't find that version it will use the first one found. It will search the directories and sub-directories based on the directory which contains the generated VB console EXE.

Thanks for the help defragster!

I also checked the memory map output to make sure the AVR and ARM version work the same and they do! :cool:

defragster
08-16-2018, 06:19 PM
Was nice to have my VS install get used and work. I'll update again in coming days and let you know what I find.

Would be nice to be able to turn it off - could you search for a specific item in the list and not generate the MAP output it is didn't exist?
Not sure if something like this would work?:: uint32_t IDE_SHOW_MAP = 100;

The bad part is I tend to use my TyCommander install because it offers a much improved build and debug environment.
> Sermon output can be static across compiles and devices
> Allows cut and paste before during and after compile - doesn't lock out or drop saved text
> More easily select one or more devices to program
> Have multiple device open in Sermon at a time from single IDE
> GUI offers RESET and Bootloader button

JoeChurchwell
08-16-2018, 06:43 PM
Yeah... No worries if you use the TyCommander. It sounds like a really cool tool set. Can you still use it when there is no USB connected? I would love to see some documentation to read through.

I think of this "tool" as just a low level easy thing to get people thinking about where their stuff actually goes in memory and what is using it all. I don't plan to make it able to turn off for my purpose since it doesn't really do anything other than display information. Also, if you de-select the verbose output from the Arduino settings then it won't display but it also won't display much of anything at that point.

Anyway... I want to make my own protocol for my omnidirectional robot that has low overhead for communication using a binary format. The higher level robot will use heuristic processing with this protocol and query by named value.

defragster
08-18-2018, 05:33 AM
Pulled the zip - and unzipped the internal zip and VS gave me a 15 KB .exe that worked to run. Second compile still generates the noted abnormal PJRC text notes.

Map looks like this. This has a library call that adds a 22KB hit that doesn't show in any way on the map. Is that something that could be pulled out and displayed? You can get the sketch from this thread <LINK> (https://forum.pjrc.com/threads/53423-Printf-revisited?p=185552&viewfull=1#post185552). And the notes in the follow posts.



T:\arduino_1.8.5_142\hardware\teensy/../tools/teensy_post_compile -file=sketch_aug12a.ino -path=T:\TEMP\arduino_build_476769 -tools=T:\arduino_1.8.5_142\hardware\teensy/../tools -board=TEENSY36 -reboot -port=usb:0/140000/0/1/1 -portlabel=COM10 (Teensy 3.6) Serial -portprotocol=Teensy
---------------------------------------------------------------------------
MEMORY MAP OUTPUT
Version 1.0.0.1
---------------------------------------------------------------------------
The Map Generator Tool Found = 3 matching executables in T:\arduino_1.8.5_142\hardware\tools\
T:\arduino_1.8.5_142\hardware\tools\objdump.exe
T:\arduino_1.8.5_142\hardware\tools\avr\avr\bin\ob jdump.exe
T:\arduino_1.8.5_142\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
MEMORY MAP GEN USING T:\arduino_1.8.5_142\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
.hidden 1fff:0000 160
.hidden 1fff:0748 16
.hidden 1fff:0758 22
.hidden 1fff:11f4 4
.hidden 1fff:12cd 1
.hidden 1fff:12ce 1
.hidden 1fff:12cf 1
.hidden 1fff:12d0 1
.hidden 1fff:12d1 1
.hidden 1fff:12d2 1
.hidden 1fff:12d3 1
.hidden 1fff:12d4 1
.hidden 1fff:12d5 1
.hidden 1fff:12d6 1
.hidden 1fff:12d7 1
.hidden 1fff:12d8 1
__global_locale 1fff:0c1c 364
__malloc_av_ 1fff:0d88 1032
__malloc_current_mallinfo 1fff:15f0 40
__malloc_max_sbrked_mem 1fff:15e8 4
__malloc_max_total_mem 1fff:15e4 4
__malloc_sbrk_base 1fff:1194 4
__malloc_top_pad 1fff:15ec 4
__malloc_trim_threshold 1fff:1190 4
__mprec_bigtens 0000:6a88 40
__mprec_tens 0000:69c0 200
_ctype_ 0000:6abc 257
_global_impure_ptr 0000:69a8 4
_impure_ptr 1fff:0c18 4
_VectorsFlash 0000:0000 464
_VectorsRam 1fff:0200 464
errno 1fff:1618 4
flashconfigbytes 0000:0400 16
usb_buffer_memory 1fff:03d0 864
***************** CRC CALCULATIONS *******************
ELF CRC = B3BBB29E
HEX CRC = 915F91DC
MAP CRC = DD7FAE7E
**************** END CRC CALCULATIONS ****************
---------------------------------------------------------------------------
END MEMORY MAP OUTPUT
---------------------------------------------------------------------------

defragster
08-18-2018, 05:38 AM
Yeah... No worries if you use the TyCommander. It sounds like a really cool tool set. Can you still use it when there is no USB connected? I would love to see some documentation to read through.

I think of this "tool" as just a low level easy thing to get people thinking about where their stuff actually goes in memory and what is using it all. I don't plan to make it able to turn off for my purpose since it doesn't really do anything other than display information. Also, if you de-select the verbose output from the Arduino settings then it won't display but it also won't display much of anything at that point.

Anyway... I want to make my own protocol for my omnidirectional robot that has low overhead for communication using a binary format. The higher level robot will use heuristic processing with this protocol and query by named value.

TyCommander was TyQt before - there is a thread for it with history and notes for anything that isn't self explanatory.

It takes USB wire to connect - it supports HID or USB Serial if that is what you mean. It serves up SerMon data and incorporates programming as well.

It would be handy for reference. I use IDE with Verbose - and this adds a double dump of that text cluttering the output on each compile - once as console then again as the output. makes it too easy to scroll past warnings - though I suppose it won't be called on errors.

Good lulck with the robot.

JoeChurchwell
08-18-2018, 09:51 PM
Pulled the zip - and unzipped the internal zip and VS gave me a 15 KB .exe that worked to run. Second compile still generates the noted abnormal PJRC text notes.

Map looks like this. This has a library call that adds a 22KB hit that doesn't show in any way on the map. Is that something that could be pulled out and displayed? You can get the sketch from this thread <LINK> (https://forum.pjrc.com/threads/53423-Printf-revisited?p=185552&viewfull=1#post185552). And the notes in the follow posts.



T:\arduino_1.8.5_142\hardware\teensy/../tools/teensy_post_compile -file=sketch_aug12a.ino -path=T:\TEMP\arduino_build_476769 -tools=T:\arduino_1.8.5_142\hardware\teensy/../tools -board=TEENSY36 -reboot -port=usb:0/140000/0/1/1 -portlabel=COM10 (Teensy 3.6) Serial -portprotocol=Teensy
---------------------------------------------------------------------------
MEMORY MAP OUTPUT
Version 1.0.0.1
---------------------------------------------------------------------------
The Map Generator Tool Found = 3 matching executables in T:\arduino_1.8.5_142\hardware\tools\
T:\arduino_1.8.5_142\hardware\tools\objdump.exe
T:\arduino_1.8.5_142\hardware\tools\avr\avr\bin\ob jdump.exe
T:\arduino_1.8.5_142\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
MEMORY MAP GEN USING T:\arduino_1.8.5_142\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
.hidden 1fff:0000 160
.hidden 1fff:0748 16
.hidden 1fff:0758 22
.hidden 1fff:11f4 4
.hidden 1fff:12cd 1
.hidden 1fff:12ce 1
.hidden 1fff:12cf 1
.hidden 1fff:12d0 1
.hidden 1fff:12d1 1
.hidden 1fff:12d2 1
.hidden 1fff:12d3 1
.hidden 1fff:12d4 1
.hidden 1fff:12d5 1
.hidden 1fff:12d6 1
.hidden 1fff:12d7 1
.hidden 1fff:12d8 1
__global_locale 1fff:0c1c 364
__malloc_av_ 1fff:0d88 1032
__malloc_current_mallinfo 1fff:15f0 40
__malloc_max_sbrked_mem 1fff:15e8 4
__malloc_max_total_mem 1fff:15e4 4
__malloc_sbrk_base 1fff:1194 4
__malloc_top_pad 1fff:15ec 4
__malloc_trim_threshold 1fff:1190 4
__mprec_bigtens 0000:6a88 40
__mprec_tens 0000:69c0 200
_ctype_ 0000:6abc 257
_global_impure_ptr 0000:69a8 4
_impure_ptr 1fff:0c18 4
_VectorsFlash 0000:0000 464
_VectorsRam 1fff:0200 464
errno 1fff:1618 4
flashconfigbytes 0000:0400 16
usb_buffer_memory 1fff:03d0 864
***************** CRC CALCULATIONS *******************
ELF CRC = B3BBB29E
HEX CRC = 915F91DC
MAP CRC = DD7FAE7E
**************** END CRC CALCULATIONS ****************
---------------------------------------------------------------------------
END MEMORY MAP OUTPUT
---------------------------------------------------------------------------

If the compile doesn't compile all the way then the map won't be correct.

This is what my output looks like:


---------------------------------------------------------------------------
MEMORY MAP OUTPUT
Version 1.0.0.1
---------------------------------------------------------------------------
The Map Generator Tool Found = 2 matching executables in C:\Program Files (x86)\Arduino\hardware\tools\
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\bin\objdump.e xe
C:\Program Files (x86)\Arduino\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
MEMORY MAP GEN USING C:\Program Files (x86)\Arduino\hardware\tools\arm\arm-none-eabi\bin\objdump.exe
__brkval 1fff:0738 4
__global_locale 1fff:0c24 364
__malloc_av_ 1fff:0d90 1032
__malloc_current_mallinfo 1fff:15ec 40
__malloc_max_sbrked_mem 1fff:15e4 4
__malloc_max_total_mem 1fff:15e0 4
__malloc_sbrk_base 1fff:119c 4
__malloc_top_pad 1fff:15e8 4
__malloc_trim_threshold 1fff:1198 4
__mprec_bigtens 0000:7078 40
__mprec_tens 0000:6fb0 200
_ctype_ 0000:6ea8 257
_global_impure_ptr 0000:6e94 4
_impure_ptr 1fff:0c20 4
_VectorsFlash 0000:0000 464
_VectorsRam 1fff:0200 464
_ZN11MillisTimer10listActiveE 1fff:12c8 4
_ZN11MillisTimer11listWaitingE 1fff:12d8 4
_ZN14EventResponder10firstYieldE 1fff:12d0 4
_ZN14EventResponder13lastInterruptE 1fff:12c4 4
_ZN14EventResponder14firstInterruptE 1fff:12c0 4
_ZN14EventResponder16runningFromYieldE 1fff:12d4 1
_ZN14EventResponder9lastYieldE 1fff:12cc 4
errno 1fff:1628 4
flashconfigbytes 0000:0400 16
Serial 1fff:0740 16
string0 1fff:07dc 4
systick_millis_count 1fff:11c0 4
test 1fff:0730 8
usb_buffer_memory 1fff:03d0 864
usb_cdc_line_coding 1fff:161c 8
usb_cdc_line_rtsdtr 1fff:12bc 1
usb_cdc_line_rtsdtr_millis 1fff:1624 4
usb_cdc_transmit_flush_timer 1fff:12ac 1
usb_configuration 1fff:12a4 1
usb_descriptor_list 0000:6e40 84
usb_endpoint_config_table 0000:6e3c 4
usb_reboot_timer 1fff:122d 1
usb_rx_byte_count_data 1fff:1614 8
usb_rx_memory_needed 1fff:1299 1
usb_string_manufacturer_name_default 1fff:0768 24
usb_string_product_name_default 1fff:07c4 22
usb_string_serial_number_default 1fff:07e0 22
***************** CRC CALCULATIONS *******************
ELF CRC = 8BE49286
HEX CRC = CF0370D3
MAP CRC = F6C713DD
**************** END CRC CALCULATIONS ****************
---------------------------------------------------------------------------
END MEMORY MAP OUTPUT
---------------------------------------------------------------------------