cmake_minimum_required(VERSION 3.21) project(sdp-dry-sensor C) set(CMAKE_CXX_COMPILER avr-g++) set(CMAKE_C_COMPILER avr-gcc) set(PROGRAMMER usbasp) add_definitions(-D'F_CPU=1000000L') set(CMAKE_CXX_FLAGS "-fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -mmcu=attiny2313 -Os -Wall -ffunction-sections -fdata-sections -flto") set(CMAKE_C_FLAGS "-std=gnu11 -fno-fat-lto-objects -mmcu=attiny2313 -Os -Wall -ffunction-sections -fdata-sections -flto") add_executable(${PROJECT_NAME}.elf config.h main.c platform.c platform.h) add_custom_command( TARGET ${PROJECT_NAME}.elf # Run after all other rules within the target have been executed POST_BUILD COMMAND avr-size -A ${PROJECT_NAME}.elf VERBATIM ) add_custom_target( upload-flash # cmake -E support copy/env/echo and so on. use cmake -E to see # COMMAND/COMMENT must be upper case #COMMAND ${CMAKE_COMMAND} -E environment COMMAND avrdude -c usbasp -p t2313a -e -Uflash:w:${PROJECT_NAME}.elf:e COMMENT "Flashing ${PROJECT_NAME}.elf to flash memory" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS ${PROJECT_NAME}.elf ) ########################################################################## add_executable(comparator-test.elf comparator-test.c comparator-test.c) add_custom_command( TARGET comparator-test.elf # Run after all other rules within the target have been executed POST_BUILD COMMAND avr-size -A comparator-test.elf VERBATIM ) add_custom_target( upload-comparator-test # cmake -E support copy/env/echo and so on. use cmake -E to see # COMMAND/COMMENT must be upper case #COMMAND ${CMAKE_COMMAND} -E environment COMMAND avrdude -c usbasp -p t2313a -e -Uflash:w:comparator-test.elf:e COMMENT "Flashing comparator-test.elf to flash memory" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS comparator-test.elf ) # avr-objcopy -O ihex -R .eeprom build/firmware.elf build/firmware.hex # avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 build/firmware.elf build/firmware-eeprom.hex # avr-size -A build/firmware.elf