Post-Building error in Segger on Mac OS

Hi, I am trying to build the latest Nearby Interaction 3.0.0 project to run on the DWM3001CDK dev board. We are building in Segger 5.70 on Mac OS. We are building the unmodified project located at Qorvo_Nearby_Interaction_3_0_0/Software/Accessory/Sources/QANI-All-FreeRTOS_QNI_3_0_0/Projects/Projects/QANI/FreeRTOS/DWM3001CDK/ses/DWM3001CDK-QANI-FreeRTOS.emProject and getting no errors during compiling or linking, but getting some error during Post-Build with no information other than “Build failed”. Does anybody know what is happening in this Post-build step and why it is failing? Is there a postbuild script somewhere that is running that we could look at? Any help is appreciated. I will paste the bottom of the build log below. Thanks!

1> Compiling ?ble_anis.c?
3> Compiling ?crc16.c?
2> Compiling ?cJSON.c?
4> Compiling ?deca_dbg.c?
3> Compiling ?mcps_crypto.c?
1> Generating linker script ?DWM3001CDK-QANI-FreeRTOS.ld?
1> Linking DWM3001CDK-QANI-FreeRTOS.elf
1> Post-Building ?DWM3001CDK-QANI-FreeRTOS?
Build failed

I will add that we have seen this same error on the Nearby Interaction 1.0.0 project so I don’t think it is anything specific to the new release.

Hi @sands!

Yes, I always get this error. The first build always fails, but if I build again right after it works.
Won’t work if you rebuild the whole project.

Best regards!

Thanks @carlos.silva. I am seeing the same behavior.

I’m still curious what is happening in this Post-build step though and what exactly is failing.

Although I am generating a hex file in /ses/Output/Common/Exe, so maybe it does not matter

I typed up a nicely formatted/detailed solution for this but I’m getting a 403 every time I try to post it.

Basically, the Post-Build command is found in Project Options->User Build Step->Post-Build Command and the command runs mergehex which is an nRF command line tool to combine the application firmware and softdevice in one hex file. Segger can not find mergehex because the PATH environment variable within Segger is different from the system PATH variable. mergehex is installed by default in /usr/local/bin which is not part of PATH within segger. So my solution was to create a script called postbuild.sh in the ses/ folder, that runs “export PATH=”$PATH":/usr/local/bin" before running mergehex. Then I change the Post-Build command in Segger to simply run my postbuild.sh script instead of running mergehex directly. This way Segger can find mergehex as a command and a merged hex file is created.

2 Likes

Wow, that was great!

Thanks, @sands!