UCLA-Rocket-Project / OLD-Ares2022-2023

Central Repository for Ares Software
3 stars 0 forks source link

Refine ADC binary compilation process. #45

Closed harrisonCassar closed 1 year ago

harrisonCassar commented 1 year ago

Addresses #39.

Improves our ADC binary compilation to obey the new desired directory structure completed with #36. Sets up nicely for #16. Rename the binary to adc from main to make more intuitive to a user. Also, removes a decent chunk of cruft (both in source code and in files tracked), serving to also fix a nonsense "unused-variable" warning we've had around for a long time.

The actual source code is the same, with the exception of commenting out a small bit of unused code, meaning our compiled binary is, functionally, the exact same as it was before.

Demonstration of Before-Change Compilation Process

...interactive terminal output... ``` $ rocket@rocket:~/adc_binary $ ls bin examples lib Makefile $ rocket@rocket:~/adc_binary $ ls bin $ rocket@rocket:~/adc_binary $ ls examples/ main.c $ rocket@rocket:~/adc_binary $ ls lib Config Driver $ rocket@rocket:~/adc_binary $ ls lib/Config/ Debug.h DEV_Config.h dev_hardware_SPI.h RPI_sysfs_gpio.h sysfs_gpio.h sysfs_software_spi.h DEV_Config.c dev_hardware_SPI.c RPI_sysfs_gpio.c sysfs_gpio.c sysfs_software_spi.c $ rocket@rocket:~/adc_binary $ ls lib/Driver ADS1263.c ADS1263.h $ rocket@rocket:~/adc_binary $ ls bin examples lib Makefile $ rocket@rocket:~/adc_binary $ make gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/Config/dev_hardware_SPI.c -o ./bin/dev_hardware_SPI.o -lbcm2835 -lm -D DEBUG ./lib/Config/dev_hardware_SPI.c:51: warning: "SPI_CS_HIGH" redefined 51 | #define SPI_CS_HIGH 0x04 //Chip select high | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:16: note: this is the location of the previous definition 16 | #define SPI_CS_HIGH _BITUL(2) /* chipselect active high? */ | ./lib/Config/dev_hardware_SPI.c:52: warning: "SPI_LSB_FIRST" redefined 52 | #define SPI_LSB_FIRST 0x08 //LSB | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:17: note: this is the location of the previous definition 17 | #define SPI_LSB_FIRST _BITUL(3) /* per-word bits-on-wire */ | ./lib/Config/dev_hardware_SPI.c:53: warning: "SPI_3WIRE" redefined 53 | #define SPI_3WIRE 0x10 //3-wire mode SI and SO same line | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:18: note: this is the location of the previous definition 18 | #define SPI_3WIRE _BITUL(4) /* SI/SO signals shared */ | ./lib/Config/dev_hardware_SPI.c:54: warning: "SPI_LOOP" redefined 54 | #define SPI_LOOP 0x20 //Loopback mode | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:19: note: this is the location of the previous definition 19 | #define SPI_LOOP _BITUL(5) /* loopback mode */ | ./lib/Config/dev_hardware_SPI.c:55: warning: "SPI_NO_CS" redefined 55 | #define SPI_NO_CS 0x40 //A single device occupies one SPI bus, so there is no chip select | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:20: note: this is the location of the previous definition 20 | #define SPI_NO_CS _BITUL(6) /* 1 dev/bus, no chipselect */ | ./lib/Config/dev_hardware_SPI.c:56: warning: "SPI_READY" redefined 56 | #define SPI_READY 0x80 //Slave pull low to stop data transmission | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/Config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:21: note: this is the location of the previous definition 21 | #define SPI_READY _BITUL(7) /* slave pulls low to pause */ | gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/Config/RPI_sysfs_gpio.c -o ./bin/RPI_sysfs_gpio.o -lbcm2835 -lm -D DEBUG gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/Config/DEV_Config.c -o ./bin/DEV_Config.o -lbcm2835 -lm -D DEBUG gcc -g -O0 -Wall -c lib/Driver/ADS1263.c -o bin/ADS1263.o -I ./lib/Config -D DEBUG gcc -g -O0 -Wall -c examples/main.c -o bin/main.o -I ./lib/Config -I ./lib/Driver -D DEBUG examples/main.c: In function ‘main’: examples/main.c:56:7: warning: unused variable ‘labels_raw’ [-Wunused-variable] 56 | char labels_raw[10][100] = {"IN0_raw", "IN1_raw", "IN2_raw", "IN3_raw", "IN4_raw", "IN5_raw", "IN6_raw", "IN7_raw", "IN8_raw", "IN9_raw"}; | ^~~~~~~~~~ echo RPI_epd RPI_epd gcc -g -O0 -Wall -D RPI ./bin/ADS1263.o ./bin/main.o ./bin/dev_hardware_SPI.o ./bin/RPI_sysfs_gpio.o ./bin/DEV_Config.o -o main -lbcm2835 -lm -D DEBUG $ rocket@rocket:~/adc_binary $ ls bin examples lib main Makefile $ rocket@rocket:~/adc_binary $ ls bin ADS1263.o DEV_Config.o dev_hardware_SPI.o main.o RPI_sysfs_gpio.o $ rocket@rocket:~/adc_binary $ ```

Demonstration of After-Change Compilation Process

...interactive terminal output... ``` $ rocket@rocket:~/adc_binary_MOD $ ls adc.c lib Makefile $ rocket@rocket:~/adc_binary_MOD $ ls lib config driver $ rocket@rocket:~/adc_binary_MOD $ ls lib/config Debug.h DEV_Config.c DEV_Config.h dev_hardware_SPI.c dev_hardware_SPI.h RPI_sysfs_gpio.c RPI_sysfs_gpio.h $ rocket@rocket:~/adc_binary_MOD $ ls lib/driver ADS1263.c ADS1263.h $ rocket@rocket:~/adc_binary_MOD $ make mkdir ./build mkdir ./build/bin gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/config/dev_hardware_SPI.c -o ./build/bin/dev_hardware_SPI.o -lbcm2835 -lm -D DEBUG ./lib/config/dev_hardware_SPI.c:51: warning: "SPI_CS_HIGH" redefined 51 | #define SPI_CS_HIGH 0x04 //Chip select high | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:16: note: this is the location of the previous definition 16 | #define SPI_CS_HIGH _BITUL(2) /* chipselect active high? */ | ./lib/config/dev_hardware_SPI.c:52: warning: "SPI_LSB_FIRST" redefined 52 | #define SPI_LSB_FIRST 0x08 //LSB | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:17: note: this is the location of the previous definition 17 | #define SPI_LSB_FIRST _BITUL(3) /* per-word bits-on-wire */ | ./lib/config/dev_hardware_SPI.c:53: warning: "SPI_3WIRE" redefined 53 | #define SPI_3WIRE 0x10 //3-wire mode SI and SO same line | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:18: note: this is the location of the previous definition 18 | #define SPI_3WIRE _BITUL(4) /* SI/SO signals shared */ | ./lib/config/dev_hardware_SPI.c:54: warning: "SPI_LOOP" redefined 54 | #define SPI_LOOP 0x20 //Loopback mode | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:19: note: this is the location of the previous definition 19 | #define SPI_LOOP _BITUL(5) /* loopback mode */ | ./lib/config/dev_hardware_SPI.c:55: warning: "SPI_NO_CS" redefined 55 | #define SPI_NO_CS 0x40 //A single device occupies one SPI bus, so there is no chip select | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:20: note: this is the location of the previous definition 20 | #define SPI_NO_CS _BITUL(6) /* 1 dev/bus, no chipselect */ | ./lib/config/dev_hardware_SPI.c:56: warning: "SPI_READY" redefined 56 | #define SPI_READY 0x80 //Slave pull low to stop data transmission | In file included from /usr/include/linux/spi/spidev.h:28, from ./lib/config/dev_hardware_SPI.c:45: /usr/include/linux/spi/spi.h:21: note: this is the location of the previous definition 21 | #define SPI_READY _BITUL(7) /* slave pulls low to pause */ | gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/config/RPI_sysfs_gpio.c -o ./build/bin/RPI_sysfs_gpio.o -lbcm2835 -lm -D DEBUG gcc -g -O0 -Wall -D USE_BCM2835_LIB -D RPI -c ./lib/config/DEV_Config.c -o ./build/bin/DEV_Config.o -lbcm2835 -lm -D DEBUG gcc -g -O0 -Wall -c lib/driver/ADS1263.c -o build/bin/ADS1263.o -I ./lib/config -D DEBUG gcc -g -O0 -Wall -c adc.c -o build/bin/adc.o -I ./lib/config -I ./lib/driver -D DEBUG gcc -g -O0 -Wall -D RPI ./build/bin/ADS1263.o ./build/bin/adc.o ./build/bin/dev_hardware_SPI.o ./build/bin/RPI_sysfs_gpio.o ./build/bin/DEV_Config.o -o ./build/adc -lbcm2835 -lm -D DEBUG $ rocket@rocket:~/adc_binary_MOD $ ls adc.c build lib Makefile $ rocket@rocket:~/adc_binary_MOD $ ls build/ adc bin $ rocket@rocket:~/adc_binary_MOD $ ls build/bin/ adc.o ADS1263.o DEV_Config.o dev_hardware_SPI.o RPI_sysfs_gpio.o $ rocket@rocket:~/adc_binary_MOD $ make clean rm -rf ./build rm -f ./build/adc $ rocket@rocket:~/adc_binary_MOD $ ls adc.c lib Makefile ```

Future Work

harrisonCassar commented 1 year ago

Based on some downstream work getting started for #16 while waiting for reviews, let's wrap up PR #46 before merging this PR.