Compiling the HAL Branch for GCC

I had the inclination tonight to try to compile the HAL firmware branch as an exe using gcc. I’ve run into a bit of trouble but instead of inquiring internally I thought I’d ask on the forums so that others might benefit from my inquiry.

First Issue:

src/spark_protocol.cpp:615:69: error: 'strnlen' was not declared in this scope

Suggestions? I actually ran into some other issues but I have been unable to replicate them.

[Edit] Adding #include <cstring> to the top of that file does not fix the issue.
[Edit] Adding #include <string.h> to the top of that file does not fix the issue.
[Edit] Apparently my compiler (MingGW) doesn’t define strnlen in string.h. ARG

Second Issue:

../services/inc/static_assert.h:17:52: error: size of array 'assert_system_health_16_bits' is negative

This stems from this call:

STATIC_ASSERT(system_health_16_bits, sizeof(eSystemHealth)==2);

which I was able to get around by changing it to

STATIC_ASSERT(system_health_16_bits, sizeof(eSystemHealth)==4); 

because enums are apparently size of 4 sometimes

Third Issue:

C:\Users\Harrison\AppData\Local\Temp\ccfOEBDs.s: Assembler messages:
C:\Users\Harrison\AppData\Local\Temp\ccfOEBDs.s:22: Error: invalid instruction suffix for `ds'
C:\Users\Harrison\AppData\Local\Temp\ccfOEBDs.s:41: Error: invalid instruction suffix for `ds'
C:\Users\Harrison\AppData\Local\Temp\ccfOEBDs.s:553: Error: no such instruction: `rbit %eax,%eax'
C:\Users\Harrison\AppData\Local\Temp\ccfOEBDs.s:586: Error: no such instruction: `rbit %eax,%eax'
make.exe[1]: *** [../build/target/hal/platform-0/./src/core-v1/core_hal.o] Error 1
make.exe": *** [hal] Error 2

Which might stem from the fact that, in order to “fix” issue 1 I simply define the prototype strnlen in string.h which probably has no corresponding function in the compiled string include but I’m not sure and will try to address that

[Edit] Nope, it apparently is not related to strnlen. Not sure where to go from here

Annnd one more. This one is definitely setup related and not HAL branch related but I’ve run into the issue why trying to compile so I thought I’d add it:

arm-none-eabi-g++.exe: fatal error: e:/spark/sparkcoreprograms/gnu tools arm embedded/4.8 2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/nano.specs: attempt to rename spec 'link' to already defined spec 'nano_link'

@harrisonhjones, I had issues until I upgraded my gcc to 4.9 ( on Windows 7x64). I’ll test again just to be sure. My problem lies with the part of the make file for the bootloader and I just have not had the time to look into it. :smile:

UPDATE: Just tested with gcc 4_9-2014q4-20141203 and it compiled without errors.

1 Like

@harrisonhjones, I should have asked… Are you compiling the private firmware HAL or the master branch HAL?

@harrisonhjones, I sometimes read stuff too fast. I assumed you were compiling the HAL for the Core but new realize you are compiling for your PC! DOH :stuck_out_tongue_winking_eye:

I am hoping to do both and I’m compiling the publicly available branch so others can follow along at home. I didn’t have time this weekend to work on it but I’ll try to get to it this week

@harrisonhjones, so how do you HAL the wireless and other hardware specific devices on the PC?

Haven’t gotten that far yet! I just wanted to get it compiled first. My plan is to implement some network stuff when I have time.

1 Like

@harrisonhjones, beauty! Did @mdma not have something running on a PC at some point?

He does but I believe it’s internal

Did you get the gcc branch compiling? I was trying it this afternoon, was thinking of finally setting up my virtualization environment, and was running into a few of the same errors.

What is HAL?

There are a few good answers in there

The gcc build was just a hack for a demo to show off the HAL. I did get a virtual core working but cut lots of corners just to make it work for the demo.

The gcc build hasn’t had any love for several months. I fixed some compiler issues yesterday, although there are still a number of missing functions needed for it to link.

The gcc build is going to be a key part of our testing infrastructure, so it should get some needed attention in the coming weeks. Yay!

1 Like