1
0
mirror of https://github.com/halleysfifthinc/Toyota-AVC-LAN synced 2025-06-07 16:06:12 +00:00

Only download Microchip pack if avr-libc doesnt support ATtiny3216

This commit is contained in:
Allen Hill 2023-08-22 11:59:41 -04:00
parent 23ea7ee463
commit eb93931522
3 changed files with 61 additions and 11 deletions

View File

@ -5,17 +5,47 @@ set(AVR_MCU "attiny3216")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/avr-gcc-toolchain.cmake") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/avr-gcc-toolchain.cmake")
project(avr-avc-lan VERSION 1 LANGUAGES C ASM) project(avr-avc-lan VERSION 1 LANGUAGES C CXX ASM)
include(FetchContent) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# attiny_atpack_SOURCE_DIR is downloaded/extracted location if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.3")
FetchContent_Declare( message(FATAL_ERROR "Insufficient AVR-GCC version; Support for ATtiny3216 was added in GCC v8")
attiny_atpack endif()
URL http://packs.download.atmel.com/Atmel.ATtiny_DFP.2.0.368.atpack endif()
URL_HASH SHA512=ee16a8ebecb57bd998a9cd4373368e3d45982cbbc3825e18d1dcac58215db6b9d907ad1ba2020cba9187fed7ba8c6f255a4fa1214e40c7a17ab2d18474f4d079
DOWNLOAD_NAME Atmel.ATtiny_DFP.2.0.368.atpack.zip # Handle libc versioning
try_compile(LIBC_VERSION_TEST
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libc-version-test.cpp"
COMPILE_DEFINITIONS -mmcu=${AVR_MCU}
) )
FetchContent_MakeAvailable(attiny_atpack)
if(NOT LIBC_VERSION_TEST)
include(FetchContent)
# attiny_atpack_SOURCE_DIR is downloaded/extracted location
FetchContent_Declare(
attiny_atpack
URL http://packs.download.atmel.com/Atmel.ATtiny_DFP.2.0.368.atpack
URL_HASH SHA512=ee16a8ebecb57bd998a9cd4373368e3d45982cbbc3825e18d1dcac58215db6b9d907ad1ba2020cba9187fed7ba8c6f255a4fa1214e40c7a17ab2d18474f4d079
DOWNLOAD_NAME Atmel.ATtiny_DFP.2.0.368.atpack.zip
)
FetchContent_MakeAvailable(attiny_atpack)
try_compile(LIBC_VERSION_TEST
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libc-version-test.cpp"
COMPILE_DEFINITIONS
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
-isystem "${attiny_atpack_SOURCE_DIR}/include"
-mmcu=${AVR_MCU}
)
if(NOT LIBC_VERSION_TEST)
message(FATAL_ERROR "Insufficient AVR-LIBC/Microchip pack for chosen MCU '${AVR_MCU}'")
else()
include_directories(SYSTEM PUBLIC "${attiny_atpack_SOURCE_DIR}/include")
add_compile_options(
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
)
endif()
endif()
set(CMAKE_C_STANDARD 17) set(CMAKE_C_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@ -38,7 +68,6 @@ add_avr_executable(sniffer
src/avclandrv.c src/avclandrv.c
src/GlobalDef.c) src/GlobalDef.c)
target_include_directories(sniffer SYSTEM PUBLIC "${attiny_atpack_SOURCE_DIR}/include")
target_link_options(sniffer PUBLIC target_link_options(sniffer PUBLIC
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}" -B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
) )
@ -46,7 +75,6 @@ target_compile_definitions(sniffer PRIVATE
F_CPU=16000000L F_CPU=16000000L
) )
target_compile_options(sniffer PRIVATE target_compile_options(sniffer PRIVATE
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
--param=min-pagesize=0 --param=min-pagesize=0
-ffunction-sections -ffunction-sections
-fdata-sections -fdata-sections

View File

@ -0,0 +1,17 @@
#if __has_include(<component-version.h>)
#include <component-version.h>
#if ((COMPONENT_VERSION_MAJOR == 1) && (COMPONENT_VERSION_MINOR == 2) && \
(BUILD_NUMBER < 118))
#error \
"Microchip pack component version greater than 1.2.118 required to support ATtiny3216"
#endif
#else
#include <avr/version.h>
#if !(__AVR_LIBC_VERSION__ > 20100UL)
#error "AVR LibC version greater than 2.1 does support ATtiny3216"
#endif
#endif
#include <avr/io.h>
int main() { return 0; }

View File

@ -47,6 +47,11 @@
__asm__ __volatile__( \ __asm__ __volatile__( \
"cbi %[vporta_out], 6;" ::[vporta_out] "I"(_SFR_IO_ADDR(VPORTA_OUT))); "cbi %[vporta_out], 6;" ::[vporta_out] "I"(_SFR_IO_ADDR(VPORTA_OUT)));
// Name difference between avr-libc and Microchip pack
#if defined(EVSYS_ASYNCCH00_bm)
#define EVSYS_ASYNCCH0_0_bm EVSYS_ASYNCCH00_bm
#endif
uint8_t CD_ID_1; uint8_t CD_ID_1;
uint8_t CD_ID_2; uint8_t CD_ID_2;