OpenCM 9.04 - How to build using the develop branch and make Pull requests


#1

Not sure if here is the best place to ask this or if I should ask this as an github issue or…

But thought I would start off here as I posted some information on how I do this with the OpenCR board as described in:

But whenever possible I try to help out some, so if I run into an issue, I like to try to fix it and then try to help out by doing a pull request back to the original sources… I have found with the OpenCM 9.04 it is a little more complicated on how to build the current sources, which are not part of the github MASTER branch, but are instead part of the DEVELOP branch.

Note: I have forked the Robotis OpenCM project and then I have cloned my fork down to my Windows 10 machine to:D:\GitHub\OpenCM9.04

The complications here is, with the normal builds, the source files are not included as part of the release, instead, there is a pre-compiled library.

Like the OPenCR I have my configuration setup, to be able to build using the current released stuff (installed using the Arduino Board manager)

How I setup to then build using the develop branch. Note I am running this on Windows 10, but I am pretty sure you can do almost identical using Linux and probably MAC.

So I create a directory under my Arduino documents folder. On my installation, the actual directory name is:C:\Users\kurte\Documents\Arduino\hardware\opencm904

Note the name opencm904 including case is important as this is used by Arduino for board type…
In this new directory I created a symbolic link: again names including case is important, but I believe the actual command was:

mklink /D opencm9.04 D:\GitHub\OpenCM9.04\arduino\opencm_arduino\opencm9.04

Then after you restart the Arduino IDE, the OpenCM9.04 board will show up twice in the Tools->Board menu

I like to edit the boards.txt file to change the name. Something like:

OpenCM904.name=OpenCM9.04 Board
OpenCM904.name=OpenCM9.04 Board(develop)

Now I am ready to start building with the new sources, Here is where I start running into issues and would like to know the way Robotis does it?

The compiling of the sources usually works, however, the link will fail. Either because it can not find the precompiled core library, or if it does, you will get duplicate name errors as it is trying to include both the new and the old…

What I did was to edit platform.txt and edit the recipe.c.combine.pattern to remove: “{build.variant.path}/{build.variant_system_lib}”

This works for me and the build goes through. Note however I am getting a compiler warning on every compile line. Note: I have verbose compiles turned on.

"C:\Users\kurte\AppData\Local\Arduino15\packages\OpenCM904\tools\opencm_gcc\5.4.0-2016q2/bin/arm-none-eabi-gcc" 	-c -g -O2 -std=gnu11  -MMD -ffunction-sections -fdata-sections -DARM_MATH_CM3 -DUSE_HAL_DRIVER -DBOARD_OpenCM904 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_OpenCM904 -DARDUINO_ARCH_OPENCM9.04    -mthumb  -DSTM32F103xB -D__OPENCM904__ "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/bsp/opencm" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/bsp/opencm/include" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw/driver" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw/usb_cdc" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/lib/STM32F1xx_HAL_Driver/Inc/" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\cores\arduino" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904" "C:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\cores\arduino\wiring_shift.c" -o "C:\Users\kurte\AppData\Local\Temp\arduino_build_442706\core\wiring_shift.c.o"
<command-line>:0:21: warning: ISO C99 requires whitespace after the macro name

"C:\Users\kurte\AppData\Local\Arduino15\packages\OpenCM904\tools\opencm_gcc\5.4.0-2016q2/bin/arm-none-eabi-gcc" 	-c -g -O2 -std=gnu11  -MMD -ffunction-sections -fdata-sections -DARM_MATH_CM3 -DUSE_HAL_DRIVER -DBOARD_OpenCM904 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_OpenCM904 -DARDUINO_ARCH_OPENCM9.04    -mthumb  -DSTM32F103xB -D__OPENCM904__ "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/bsp/opencm" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/bsp/opencm/include" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw/driver" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/hw/usb_cdc" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/lib/STM32F1xx_HAL_Driver/Inc/" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904/" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\cores\arduino" "-IC:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\variants\OpenCM904" "C:\Users\kurte\Documents\Arduino\hardware\opencm904\opencm9.04\cores\arduino\avr\dtostrf.c" -o "C:\Users\kurte\AppData\Local\Temp\arduino_build_442706\core\avr\dtostrf.c.o"
<command-line>:0:21: warning: ISO C99 requires whitespace after the macro name
...

So recently I did a minor Pull Request to OpenCM, which was accepted :smiley: However it appears like, to do it fully properly, you need some additional stuff done, which I believe maybe includes:

Copy any new/updated header files to release directory, so in my case the files need to be updated in:

D:\GitHub\OpenCM9.04\arduino\opencm_arduino\opencm9.04_release\cores\arduino

And for any changed library do you also update the sources in the release folder as well?
In particular:

D:\GitHub\OpenCM9.04\arduino\opencm_arduino\opencm9.04_release\variants\OpenCM904\lib_f103.a

Is this a copy of the core.a that Arduino created in the temp directory. In my latest case the file:

C:\Users\kurte\AppData\Local\Temp\arduino_build_442706\core\core.a

Again I am able to build using the current stuff, but would be great if I was doing it in way that was consistent in how it is done at Robotis.

Thanks,
Kurt


#2

Quick update: I thought I would try this out on my MAC portable, so I did all of the same stuff, of cloning my fork of the github project down to my mac into my Documents\Github\OpenCM9.04 directory.

I created the hardware folder, created the opencm… folder
I used the linux command: ln -s <source directory <destination directory)

I then tried the build and the compile through with all of the same warnings ISO C99…

Then the link failed as open the lib_f103.a file and failed.

I thought I would try a different approach and this type, I created an empty library, by using terminal window, cd to the directory that the lib file was searched for.

I then used the AR command to create an empty library:

<full path to arm-non-eabi-ar> rcs lib_f103.a

I then reran the arduino build and it completed without error :smiley: I have not tried downloading the new program yet, but my guess is it should be fine.


(Kei) #3

Hi, @KurtE

After modifying the code in OpenCM9.04/arduino/opencm_arduino/opencm9.04/ directory, build through EclipseIDE, a library file (.a) is created.

Then copy this file to variants/OpenCM904 in the release folder.
Also, if any .h files have been changed, you must also overwrite them in the corresponding header file location in the release folder.


#4

Thanks @OpusK,

So far I believe that i have uploaded the header files into the release folder.

I do see that the project appears to have some files associated with eclipse project.

However I am not 100% sure on how to make them work…

I tried doing a build on Windows, I have a recent version of Sloeber installed (Eclipse with Arduino plugin).
I tried to import file those projects into eclipse workspace and tried a build or build all, but it would just say nothing to build.

I then tried booting up my older machine, which I have Ubuntu 18.04.01 64 bits installed. I tried installing eclipse using sudo apt-get install eclipse, which installed but failed to run, so after googling I uninstalled it and then downloaded the eclipse installer app. I then choose the install eclipse to compile for C/C++, I then again tried adding those OpenCM projects into workspace. Eclipse error manager showed several errors…
Note: I installed the three different gcc-arm-… installations to make sure I had cross compilers installed.
Still said nothing to build…

I then looked at project settings for the compiler it complained that the ARM GCC build chain was orphaned.

So any suggestions on how to setup to build this project with Eclipse would be great!

Also still wonder about the huge size of the generated .a file. My guess is it has lots of debug stuff in it?

thanks again
Kurt


(Kei) #5

@Kurt,

The project that creates the library (.a) does not need the Arduino plugin.
It is simply generic firmware.

Currently, you need to use the Eclipse IDE. If you have a separate Makefile, you can do it without an IDE.

If you need more information about installing and configuring the Eclipse CDT IDE, please see the link below. I hope it helps.

The current compile optimization option is -O2.
I think, if we want to reduce the size of this library file, might need to optimize the size of your code.


#6

Thanks @OpusK,

I was able to use your links above and get a version of Eclipse that succeeded in building the archive file.

As for size, I believe it is building a debug version of the code so there may be lots of debug symbols and the like that is included into the library (not necessarily into the binary after Arduino links with it.).

Again what caught my eye, is when you are building using the develop branch where you are building against the sources. Arduino builds the core and generates core.a which when possible it uses for the next builds assuming nothing in the core changed.

And with this mornings build, core.a is 323KB, whereas lib_f103.a is 68389KB.

Now I understand it includes additional stuff, such as the probably several of the libraries. Also I don’t know if core.a includes the binaries out of variants…

Just curious.

The good news is with the above information, now have enough information on how to successfully build from the develop branch, make changes and how to generate the necessary stuff to create a Pull Request.

Thanks again


#7

Not sure if anyone else is doing like I have done above, and be able to host both the released version as well as the develop version.

But ever since I was doing this, I was running into lots of compiler warnings. With a command line warning for each compiler line generated… Finally it bugged me enough to try some stuff to resolve it.

Turns out the issue is with my link name, which generate a define: -DARDUINO_ARCH_OPENCM9.04
Which caused the warning…

The problem was with the line:

mklink /D opencm9.04 D:\GitHub\OpenCM9.04\arduino\opencm_arduino\opencm9.04

You can get rid of the compiler warnings, by changing the link line to:

mklink /D OpenCM904  D:\GitHub\OpenCM9.04\arduino\opencm_arduino\opencm9.04

This was the Windows command, similar change for Linux setup…

Note: the character case of the name is important in that it will remove other compiler warning about this library is built for …

Note: you can fix current installs that give you these warnings, by renaming the link.
However if you have the board as your current Arduino board and you rename the link, Arduino may not load or compile correctly, so first choose a different board type. Exit Arduino, rename link and run Arduino again choosing your develop install.