LGT-92_-LoRa_GPS_Tracker icon indicating copy to clipboard operation
LGT-92_-LoRa_GPS_Tracker copied to clipboard

Proper gcc build support

Open tormodvolden opened this issue 3 years ago • 8 comments

Did anyone already build this firmware with gcc?

tormodvolden avatar Sep 14 '21 14:09 tormodvolden

I am pretty far on a working Makefile, just some newlib linking issues left to sort out.

GNU make gets pretty upset by parentheses in the path names. Would you please consider renaming the Projects/Multi/Applications/LoRa/DRAGINO-LRWAN(AT) folder to something without parentheses? For instance DRAGINO-LRWAN_AT?

tormodvolden avatar Sep 19 '21 20:09 tormodvolden

We can now build working firmware cleanly with open-source tools! For now, see my gcc branch at https://github.com/tormodvolden/LGT-92_-LoRa_GPS_Tracker/tree/gcc

Caveats: The built binary is currently a bit larger than the stock firmware and would overlap with where settings were stored in flash. So these settings must be copied from 0x19000 to 0x1fe00 (e.g. 512 bytes) before flashing the gcc build.

tormodvolden avatar Oct 11 '21 10:10 tormodvolden

Fixed (with above caveats still not sorted out) in commit f188584.

tormodvolden avatar Nov 17 '21 09:11 tormodvolden

I have pushed my WIP to https://github.com/tormodvolden/LGT-92_-LoRa_GPS_Tracker/commits/gcc_1_6_7 for those who want to try out building with gcc. I want to rework the FLASH_USER_FDR_STATE stuff before I make a merge request for it.

tormodvolden avatar Nov 17 '21 11:11 tormodvolden

We should add a README with a big fat warning that if you simply flash your LGT-92 with the result of the build, it will wipe out the flash settings with LORA IDs and keys etc. Maybe the Makefile flash target should check that there are flash settings at the new, higher location before proceeding to flash the firmware.

tormodvolden avatar Nov 17 '21 11:11 tormodvolden

Here is a shell script that copies the flash settings to the new location, if it hasn't been done before. It uses some crude heuristics to discern settings, code, or empty. Review and testing is welcome. (EDIT: backup_flash_settings.sh script was moved to git)

tormodvolden avatar Nov 17 '21 17:11 tormodvolden

I have reworked the FLASH_USER stuff to be upstream compatible and made a merge request, including other smaller clean-ups. The gcc Makefile will now refuse to flash unless there is a backup file of the settings. The backup script is in the gcc folder. My gcc_1_6_7 branch is rebased on top of this.

EDIT: Gone the more pragmatic way and have the linker script wrap the code around the original flash settings, it is not pretty but makes it fully compatible with the official firmware, keeping the flash settings at the same location. This makes it so much easier to switch back and forth between the official binaries and the gcc build. Backing up the settings is always good and highly recommended, but in principle shouldn't be needed.

tormodvolden avatar Jan 21 '22 09:01 tormodvolden

Somebody asked me how to actually build it: Just "cd" to the gcc folder and run "make". There are some hints in the commit f188584 message, but obviously this belongs in a README.gcc file or similar.

tormodvolden avatar Feb 01 '22 09:02 tormodvolden