diff --git a/blink-cmake/CMakeLists.txt b/blink-cmake/CMakeLists.txt
index 03730c8520a50bce1d43e583ed316842b7406021..de8c9d051405f9ce63589888bad7b7f4df3bad09 100644
--- a/blink-cmake/CMakeLists.txt
+++ b/blink-cmake/CMakeLists.txt
@@ -1,43 +1,66 @@
 cmake_minimum_required(VERSION 3.13) # 3.13 is required for target_link_options
 project(HelloSAMD51 C)
 
-#set(CMAKE_SYSTEM_NAME Generic)
-#set(CMAKE_SYSTEM_PROCESSOR arm)
-#set(CMAKE_CROSSCOMPILING 1)
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_SYSTEM_PROCESSOR arm)
+set(CMAKE_CROSSCOMPILING 1)
+set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
+#set(CMAKE_C_LINKER "arm-none-eabi-gcc")
+set(CMAKE_C_LINK_FLAGS "")
+
+set(MCU_DEFINE "__SAMD51J19A__")
 
 if(NOT CMAKE_BUILD_TYPE)
-    set(CMAKE_BUILD_TYPE "Release")
+    set(CMAKE_BUILD_TYPE "Debug")
 endif()
 message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
 
-add_library(asf INTERFACE)
-target_include_directories(asf INTERFACE
+add_library(asf
+    samd51/startup/startup_samd51.c
+    samd51/startup/system_samd51.c
+)
+target_include_directories(asf PUBLIC
     ${CMAKE_CURRENT_SOURCE_DIR}/samd51
     ${CMAKE_CURRENT_SOURCE_DIR}/samd51/CMSIS/Include
     ${CMAKE_CURRENT_SOURCE_DIR}/samd51/include
     ${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup
 )
-target_link_options(asf INTERFACE
+target_link_libraries(asf m)
+target_link_options(asf PUBLIC
     -mthumb
     -mabi=aapcs-linux
-    -mlong-calls
+    #-mlong-calls
     -mcpu=cortex-m4
-    -mfloat-abi=softfp
     -mfpu=fpv4-sp-d16
+    -mfloat-abi=softfp
     -DSAMD51
+    -T${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup/samd51j19a_flash.ld
+    -L${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup
+    #-Wl,--start-group
+    #-Wl,--end-group
+    #-Wl,-Map="main.map"
+    --specs=nano.specs
+    -Wl,--gc-sections
 )
-
-add_executable(hello_world
-    main.c
-)
-target_link_libraries(hello_world asf)
-target_compile_options(hello_world PRIVATE
+target_compile_options(asf PUBLIC
+    -D${MCU_DEFINE}
     -x c
     -DDEBUG
     -Os
     -ffunction-sections
-    -g3
+    #-g3
     -Wall
-    -c
     -std=gnu99
+    -mthumb # use T32 instruction set instead of A32 (don't know if this matters)
+    -mabi=aapcs-linux
+    #-mlong-calls # changes how functions are called
+    -mcpu=cortex-m4
+    -mfpu=fpv4-sp-d16
+    -mfloat-abi=softfp # this flag specifies whether to use software or hardware float operations
+    -DSAMD51
 )
+
+add_executable(hello_world
+    main.c
+)
+target_link_libraries(hello_world asf)