diff --git a/.gitea/workflows/sdcc.yml b/.gitea/workflows/sdcc.yml new file mode 100644 index 0000000..b0c313e --- /dev/null +++ b/.gitea/workflows/sdcc.yml @@ -0,0 +1,57 @@ +name: SDCC Build for CC2530 + +on: + workflow_dispatch: + # push: + # branches: + # - main + # pull_request: + # branches: + # - main + +jobs: + build: + runs-on: ubuntu-latest # Runs on the latest Ubuntu version available + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + github-server-url: ${{ vars.GIT_SERVER_URL }} + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgmp-dev libmpfr-dev libncurses-dev git + + - name: Clone SDCC repository + run: | + git clone https://github.com/sdcc-team/sdcc.git + cd sdcc + + - name: Build SDCC + run: | + cd sdcc + ./configure --target=8051 --with-arch=8051 --prefix=/usr/local + make + sudo make install + + - name: Verify SDCC installation + run: | + sdcc --version # Verifies if SDCC was installed successfully + + - name: Compile using Makefile + run: | + cd $GITHUB_WORKSPACE # Navigate to the root of your repo (where the Makefile is located) + make # Run the make command to build the project using the Makefile + + # - name: Upload compiled hex file + # uses: actions/upload-artifact@v2 + # with: + # name: cc2530-firmware + # path: output.ihx # Replace with the actual output file name if different (e.g., .ihx) + + - name: Clean up compiled files + run: | + cd $GITHUB_WORKSPACE # Navigate back to the project directory + make clean # Run the 'make clean' command to delete the compiled files \ No newline at end of file diff --git a/Makefile b/Makefile index e3ca0f8..fc251e7 100644 --- a/Makefile +++ b/Makefile @@ -7,27 +7,29 @@ ZSTACK_DIR = ./include INCLUDE_DIRS = -I$(ZSTACK_DIR) # Compiler settings -CC = msp430-elf-gcc # MSP430 compiler -# CFLAGS (C Compiler flags) -CFLAGS = $(INCLUDE_DIRS) -Wall -O2 # Enable all warnings, Optimize for size -LDFLAGS = -LIBS = -lZStack -lhal # ZStack for Zigbee communication, lhal for Hardware Abstraction Layer library +CC = sdcc # sdcc compiler +CFLAGS = -mmc51 $(INCLUDE_DIRS) # add include paths to compiler flags -SRCS = main.c zigbee_comm.c sensors/bme280.c sensors/wind_vane.c sensors/rain_gauge.c sensors/anemometer.c include/hal_timer.c +SRC=$(wildcard *.c) HEADERS = main.h zigbee_comm.h sensors/bme280.h sensors/wind_vane.h sensors/rain_gauge.h sensors/anemometer.h config.h include/hal_types.h include/hal_defs.h include/hal_timer.h include/ZComDef.h include/OSAL.h include/i2c.h -OBJS = $(SRCS:.c=.o) # create a list of object files from the source files -all: main.elf +# Object files (replace .c with .o) +OBJS = $(SRCS:.c=.o) -main.elf: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ +# Output file +OUTPUT=output.ihx +# Default target: compile and generate the hex file +all: $(OUTPUT) + +# Rule to build the output file +$(OUTPUT): $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $(OUTPUT) + +# Rule to build object files from source files %.o: %.c $(HEADERS) $(CC) $(CFLAGS) -c $< -o $@ +# Clean generated files clean: - rm -f main.elf $(OBJS) - -# Optionally add a rule to flash your device (if applicable) -# flash: main.elf -# ./flash_tool main.elf # This is just a placeholder if needed \ No newline at end of file + rm -f $(OUTPUT) $(OBJS) *.asm *.lst *.sym \ No newline at end of file diff --git a/Makefile.old b/Makefile.old new file mode 100644 index 0000000..e3ca0f8 --- /dev/null +++ b/Makefile.old @@ -0,0 +1,33 @@ +# Path to Z-Stack SDK +ZSTACK_DIR = ./include + +# Include path for the Z-Stack SDK +# INCLUDE_DIRS = -I$(ZSTACK_DIR)/Components/hal/CC2530 \ +# -I$(ZSTACK_DIR)/Components/zigbee +INCLUDE_DIRS = -I$(ZSTACK_DIR) + +# Compiler settings +CC = msp430-elf-gcc # MSP430 compiler +# CFLAGS (C Compiler flags) +CFLAGS = $(INCLUDE_DIRS) -Wall -O2 # Enable all warnings, Optimize for size +LDFLAGS = +LIBS = -lZStack -lhal # ZStack for Zigbee communication, lhal for Hardware Abstraction Layer library + +SRCS = main.c zigbee_comm.c sensors/bme280.c sensors/wind_vane.c sensors/rain_gauge.c sensors/anemometer.c include/hal_timer.c +HEADERS = main.h zigbee_comm.h sensors/bme280.h sensors/wind_vane.h sensors/rain_gauge.h sensors/anemometer.h config.h include/hal_types.h include/hal_defs.h include/hal_timer.h include/ZComDef.h include/OSAL.h include/i2c.h +OBJS = $(SRCS:.c=.o) # create a list of object files from the source files + +all: main.elf + +main.elf: $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +%.o: %.c $(HEADERS) + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -f main.elf $(OBJS) + +# Optionally add a rule to flash your device (if applicable) +# flash: main.elf +# ./flash_tool main.elf # This is just a placeholder if needed \ No newline at end of file