Author Topic: Looking for example of "Post-build steps"  (Read 42463 times)

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Looking for example of "Post-build steps"
« on: November 30, 2016, 07:09:00 pm »
Hello,

I want to integrate arm-elf-objdump tool in Code::Blocks, that disassemble an object file.
I want it to runs immediately after build is terminated.
So I considered that "Post-build steps" option is the best location to integrate arm-elf-objdump into processing flow.
But unfortunately I didn't find any document that would help me to resolve the problem.

Anyway I've just tried command-line case for arm-elf-objdump (this way this command is executed from command line).
Without surprises it didn't work ... none disassembly file was generated.
Certainly, the Post-build step command have a particular syntax that probably uses placeholders for input/output and flags.
Is someone aware of such kind of things ?
Thanks.



Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #1 on: November 30, 2016, 08:02:52 pm »
Small correction: the correct name of the command is arm-none-eabi-objdump, the name I used in previous message is from old version of "GNU Tools ARM Embedded"

Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Looking for example of "Post-build steps"
« Reply #2 on: December 01, 2016, 08:11:38 am »
I'm not sure, if output redirection works directly from the post-build steps.
You probably can call objdump within it's own cmd instance like:

Code
cmd /C "arm-elf-objdump ... "

but then you have to set the paths to the compiler executable and the object files. You can use Code::Blocks variables for this (cf. http://wiki.codeblocks.org/index.php/Variable_expansion).
Alternatively, you can put the whole command in a batch file and start it from the post-build steps (again, with the full path to the compiler and object files).

The result of the post-build step execution is shown in the Build Log. Just check the messages there if anything doesn't work as expected.

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #3 on: December 01, 2016, 12:41:28 pm »
Thanks Christobal,

I've tried your suggestion. For the moment it doesn't work.
But I think it's a right way to explore.
At least I've found a conformation of your idea (please, see the screenshot from Block::Code help).
But in order to accelerate workaround, indeed it would be nice to consult with build log.
But I couldn't find it. Have you en idea where it's located ?


Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Looking for example of "Post-build steps"
« Reply #4 on: December 01, 2016, 02:54:30 pm »
Post-build messages are displayed in the "Build log" tab or in the generated Build Log html file.

Right at the end of the Build log, you should see something like:

Code
Output file is ..\result\Core0.elf with size 406.01 KB
[100.0%] Running target post-build steps
tricore-objcopy -O ihex  ..\result\Core0.elf ..\result\Core0.hex
Process terminated with status 0 (0 minute(s), 9 second(s))
0 error(s), 0 warning(s) (0 minute(s), 9 second(s))
Build log saved as:

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #5 on: December 01, 2016, 03:33:43 pm »
Here is Build log for simplest .c file.
Note, that I introduced deliberately erroneous post-build command, but its action wasn't reflected in Build log.
Any comments ?

Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Looking for example of "Post-build steps"
« Reply #6 on: December 01, 2016, 04:36:06 pm »
You have to build the project. Not just the file ...

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #7 on: December 01, 2016, 04:57:17 pm »
For the moment I can't build entire projects.
Build generates errors for reasons that I don't understand for the moment.
Without doubt the GNU Tools ARM Embedded tool-chain isn't properly integrated into Code::Blocks ... but it's the subject of my other post published earlier.
I searched for a solution on the forums dedicated to ARM and GCC, but still have no solution.
Here below is the screenshot of project build log.
There is no messages concerned with "post-build", but certainly it's due to the fact that build failed.



Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Looking for example of "Post-build steps"
« Reply #8 on: December 01, 2016, 10:36:52 pm »
There is no messages concerned with "post-build", but certainly it's due to the fact that build failed.
exactly. Post build steps are only executed if the build succeeds. You can create a tool with the tools+ plugin for now, so you can execute the objdump command from the menu with the current file...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Looking for example of "Post-build steps"
« Reply #9 on: December 02, 2016, 09:24:35 am »
Pavel_47: Have you seen this page http://wiki.codeblocks.org/index.php/Adding_support_for_non_C/C%2B%2B_files_to_the_build_system it might be useful for your case.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Looking for example of "Post-build steps"
« Reply #10 on: December 02, 2016, 09:44:05 am »
For the moment I can't build entire projects.
Build generates errors for reasons that I don't understand for the moment.
Without doubt the GNU Tools ARM Embedded tool-chain isn't properly integrated into Code::Blocks ... but it's the subject of my other post published earlier.
It's not an issue with the ARM GCC integration into Code::Blocks. I assume that you are new to Embedded programming...
Compared to PC applications, you have to do some extra work that cannot be provided by the Compiler toolchain, as it is dependent on the device that the code is intended to run. Additionally, on embedded targets there is a startup - code, which provides basically the functionality of an OS Loader. The startup code sets up the environment for your application and requires information from the linker script.
This means (if you want to start from scratch) that you have to provide some low-level routines and settings.

Your problem(s) seem to be:
The linker script doesn't seem to export the boundary addresses for the .bss section (check "target.ld"; it probably needs some adaption according to the processor derivate you want to use). The linker script should also define memory for stack and heap.
The boundary addresses are used by the startup code (crt0.o) to determine all variables that shall be cleared before main is entered. The startup code does also initialize the .data sections with pre-defined values. If you don't know about .bss and .data sections, the GCC linker (LD) manual and google can help you.
You should also check the crt0.S source to get a grasp about what is happening there. Maybe yo need/want to do some adaptions there as well, so you can provide your own crt0.S and pass the -nocrt0 option to the linker.

Your interrupt vector table is missing. It probably needs to be located at a certain position in memory, as the processor will jump to this location on any interrupt or trap event. From there the table should forward jump to your interrupt service routines. Some processors allow to have the interrupt table at an arbitrary (aligned) memory location. For this they provide a special register to set up the interrupt vector base address. The processors user manual can give you more information about the requirements for the interrupt system.
Keep in mind, that the Toolchain doesn't provide you with anything interrupt related (maybe except for example files). It is your job to initialize the Interrupt system if you want to use interrupts.

The _exit function is a stub routine that gives you the possibility to execute target dependent code before the processor halts. For now, it will suffice if you provide an empty routine, which does nothing. In embedded programming it is common that your main routine doesn't return anyway...

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #11 on: December 03, 2016, 02:44:00 pm »
Thanks,

Yes, the problem is in divergence of names used in linker scripts from Code::Blocks and GNU Tools ARM Embedded.
I pointed my compiler executables to GNU Tools ARM Embedded bin directory. So, the linker uses libraries (e.g. crt0.o) also from GNU Tools ARM Embedded.
The crt0.o uses symbols __bss_start__ and __bss_end__, that are properly defined in
C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\share\gcc-arm-none-eabi\samples\ldscripts\gcc.ld

Whereas linker script is called from
C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\arm\files\ARM-eval7t\ld\target.ld, where the similar symbols are __bss_start and __bss_end
Its location is defined here (highlighted in yellow):



I've tried to point to "custom" makefile from C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\share\gcc-arm-none-eabi\samples\src\cpp that calls gcc.ld script with correct symbols, but build failed:



 

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #12 on: December 03, 2016, 04:47:15 pm »
Here I've just tried to build with toolchain executables from Code::Blocks bin.
I'm not sure if I correctly restituted the initial settings (i.e. executables for compiler, linker, etc.).
Anyway, errors occur:


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Looking for example of "Post-build steps"
« Reply #13 on: December 03, 2016, 07:11:46 pm »
Quote
Here I've just tried to build with toolchain executables from Code::Blocks bin.
this is bul****  you can't compile arm code with a x86 compiler (you can but you will get errors)
Also x86 don't need linker scripts...

Quote
Whereas linker script is called from
C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\arm\files\ARM-eval7t\ld\target.ld, where the similar symbols are __bss_start and __bss_end
Its location is defined here (highlighted in yellow):
No, it calls the linker script:
Code
-T ld/target
it calls the linker script from a sub folder of your project. Replace this script file with your appropriate linker file or fix the path in the linker settings

then, if you still get errors don't post screenshots. They waste space. Post the build log (from the build log tap) in code tags (the # symbol in the new post editor)

hope this helps

greetings

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Looking for example of "Post-build steps"
« Reply #14 on: December 04, 2016, 10:58:03 am »
Quote
Here I've just tried to build with toolchain executables from Code::Blocks bin.
this is bul****  you can't compile arm code with a x86 compiler (you can but you will get errors)
Also x86 don't need linker scripts...

If I properly understood you, none executable, located in "C:\Program Files (x86)\CodeBlocks\MinGW\bin", can properly process (i.e. compile, link) ARM code. Correct ?
If this is correct in order to work with ARM targets, it's necessary to install "GNU Tools ARM Embedded" toolchain.
If these 2 above statements are correct, one question arises:
What could be the usage of the link scripts, located in  "C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\arm\files\{ARM_platform_name}\ld\" directories if:
  • these scripts are not compatible with crt0.o library, located in "GNU Tools ARM Embedded" toolchain
  • there is no any linker, located in "C:\Program Files (x86)\CodeBlocks\MinGW\bin", capable to correctly process them
Thanks.