Custom samd21 board error uploading sketch

Having problems uploading first sketch to custom minimal samd21G18 (no led’s or crystal on board)

schematic: ( new user and can't upload files)

getting this error message in the ide during upload

Arduino: 1.8.17 (Linux), Board: "Arduino Zero (Native USB Port)"
​
Sketch uses 11940 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 2204 bytes (6%) of dynamic memory, leaving 30564 bytes for local variables. Maximum is 32768 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
Uploading using selected port: /dev/ttyACM0
/home/user/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac -i -d --port=ttyACM0 -U true -i -e -w -v /tmp/arduino_build_539030/ASCIITable.ino.bin -R 
Set binary mode
readWord(addr=0)=0x20007c00
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZP] Nov  3 2021 05:02:11
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007c00
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007c00
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZP] Nov  3 2021 05:02:11
Version      : v2.0 [Arduino:XYZP] Nov  3 2021 05:02:11
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0
0readWord(addr=0x41004020)=0
,1readWord(addr=0x41004020)=0
,2readWord(addr=0x41004020)=0
,3readWord(addr=0x41004020)=0
,4readWord(addr=0x41004020)=0
,5readWord(addr=0x41004020)=0
,6readWord(addr=0x41004020)=0
,7readWord(addr=0x41004020)=0
,8readWord(addr=0x41004020)=0
,9readWord(addr=0x41004020)=0
,10readWord(addr=0x41004020)=0
,11readWord(addr=0x41004020)=0
,12readWord(addr=0x41004020)=0
,13readWord(addr=0x41004020)=0
,14readWord(addr=0x41004020)=0
,15
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0
BOD          : false
readWord(addr=0x40000834)=0
BOR          : false
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.055 seconds
​
Write 11940 bytes to flash (187 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)
[==========                    ] 34% (64/187 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)
An error occurred while uploading the sketch
[====================          ] 68% (128/187 pages)write(addr=0x20005000,size=0xec0)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0xec0)
[==============================] 100% (187/187 pages)
done in 0.034 seconds
​
Verify 11940 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = e03e
Verify failed

I was able to flash the bootloader successfully using atmel studio and a jlink mini.

Before compiling the bootloader I modified the board_definitions_arduino_zero.h adding in

#define CRYSTALLESS (1)

and commenting out the board_led_pin, board_led_rxpin, board_led_txpin lines

the board is recognized in linux and gets assigned a port inside the arduino ide.

this line was modified in boards.txt:

arduino_zero_native.build.extra_flags= -DCRYSTALLESS -D__SAMD21G18A__ {build.usb_flags}

note: this chip was harvested from a wemos/robodyn arduino zero clone board. before taking the chip
from that board I was getting the same error during upload. (I think, can’t remember the exact error but was unable to upload a sketch)