danielnilsson9 / bbs-fw

Open source firmware for multiple electric bike motor controllers.
GNU General Public License v3.0
191 stars 39 forks source link

go from makefile to Makefile usable on linux for building the firmware #236

Closed aalm closed 1 month ago

aalm commented 2 months ago

also flashing can be done with given arguments(change ttyUSB0 to whatever you have it on):

$ stcgal -P stc15 -p /dev/ttyUSB0 -b 57600 -t 20000 bbs-fw.hex Waiting for MCU, please cycle power: done Target model: Name: STC15F2K60S2 Magic: F408 Code flash: 60.0 KB EEPROM flash: 1.0 KB Target frequency: 19.997 MHz Target BSL version: 7.2.5S Target wakeup frequency: 35.050 KHz Target options: reset_pin_enabled=False clock_source=internal clock_gain=high watchdog_por_enabled=False watchdog_stop_idle=True watchdog_prescale=256 low_voltage_reset=True low_voltage_threshold=3 eeprom_lvd_inhibit=True eeprom_erase_enabled=False bsl_pindetect_enabled=False por_reset_delay=long rstout_por_state=low uart2_passthrough=False uart2_pin_mode=normal cpu_core_voltage=unknown Loading flash: 22288 bytes (Intel HEX) Trimming frequency: 19.991 MHz Switching to 57600 baud: done Erasing flash: done Writing flash: 22592 Bytes [00:08, 2661.06 Bytes/s]
Finishing write: done Setting options: done Target UID: F408C4170E8928 Disconnected!

csutcliff commented 2 months ago

works for me, lets get this merged!

danielnilsson9 commented 2 months ago

Will merge this. Tested and still works in Windows?

csutcliff commented 2 months ago

it does still work fine, however it adds the ugly output: process_begin: CreateProcess(NULL, uname, ...) failed. because uname isn't a valid command on windows. The UNAME variable being blank still functions as intended for the rest of the makefile.

You can improve the detection and replace the error with some useful output by replacing the line UNAME := $(shell uname) with:

ifeq '$(findstring ;,$(PATH))' ';'
    UNAME := Windows
else
    UNAME := $(shell uname 2>/dev/null || echo Unknown)
    UNAME := $(patsubst CYGWIN%,Cygwin,$(UNAME))
    UNAME := $(patsubst MSYS%,MSYS,$(UNAME))
    UNAME := $(patsubst MINGW%,MSYS,$(UNAME))
endif

$(info $(UNAME) host detected)

Tested on both Linux and Windows.

danielnilsson9 commented 1 month ago

Please fix so it doesn't print the error messages on windows and I will merge this

aalm commented 1 month ago

Please fix so it doesn't print the error messages on windows and I will merge this

Done.

danielnilsson9 commented 1 month ago

Thank you!