Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Burn Bootloader SAMD. #65

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions sparkfun/samd/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,62 @@ samd21_proRF.build.pid=0x214F
samd21_proRF.bootloader.tool=openocd
samd21_proRF.bootloader.file=zero/Sparkfun_SAMD21_ProRF.bin

samd21_proRF_no_bl.name=SparkFun SAMD21 Pro RF (no bootloader, 8 MHz)
samd21_proRF_no_bl.vid.0=0x1B4F
samd21_proRF_no_bl.pid.0=0x214F
samd21_proRF_no_bl.vid.1=0x1B4F
samd21_proRF_no_bl.pid.1=0x215F
samd21_proRF_no_bl.upload.tool=bossac
samd21_proRF_no_bl.upload.protocol=sam-ba
samd21_proRF_no_bl.upload.maximum_size=262144
samd21_proRF_no_bl.upload.use_1200bps_touch=true
samd21_proRF_no_bl.upload.wait_for_upload_port=true
samd21_proRF_no_bl.upload.native_usb=true
samd21_proRF_no_bl.build.mcu=cortex-m0plus
samd21_proRF_no_bl.build.f_cpu=8000000L
samd21_proRF_no_bl.build.usb_product="SFE SAMD21 Pro RF"
samd21_proRF_no_bl.build.usb_manufacturer="SparkFun"
samd21_proRF_no_bl.build.board=SAMD_ZERO
samd21_proRF_no_bl.build.core=arduino
samd21_proRF_no_bl.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
samd21_proRF_no_bl.build.ldscript=linker_scripts/gcc/flash_without_bootloader.ld
samd21_proRF_no_bl.build.openocdscript=openocd_scripts/arduino_zero.cfg
samd21_proRF_no_bl.build.variant=SparkFun_ProRF
samd21_proRF_no_bl.build.variant_system_lib=
samd21_proRF_no_bl.build.extra_combine_flags=
samd21_proRF_no_bl.build.vid=0x1B4F
samd21_proRF_no_bl.build.pid=0x214F
samd21_proRF_no_bl.bootloader.tool=openocd
samd21_proRF_no_bl.bootloader.file=zero/Sparkfun_SAMD21_ProRF.bin

samd21_proRF_no_bl_24.name=SparkFun SAMD21 Pro RF (no bootloader, 24 MHz)
samd21_proRF_no_bl_24.vid.0=0x1B4F
samd21_proRF_no_bl_24.pid.0=0x214F
samd21_proRF_no_bl_24.vid.1=0x1B4F
samd21_proRF_no_bl_24.pid.1=0x215F
samd21_proRF_no_bl_24.upload.tool=bossac
samd21_proRF_no_bl_24.upload.protocol=sam-ba
samd21_proRF_no_bl_24.upload.maximum_size=262144
samd21_proRF_no_bl_24.upload.use_1200bps_touch=true
samd21_proRF_no_bl_24.upload.wait_for_upload_port=true
samd21_proRF_no_bl_24.upload.native_usb=true
samd21_proRF_no_bl_24.build.mcu=cortex-m0plus
samd21_proRF_no_bl_24.build.f_cpu=24000000L
samd21_proRF_no_bl_24.build.usb_product="SFE SAMD21 Pro RF"
samd21_proRF_no_bl_24.build.usb_manufacturer="SparkFun"
samd21_proRF_no_bl_24.build.board=SAMD_ZERO
samd21_proRF_no_bl_24.build.core=arduino
samd21_proRF_no_bl_24.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
samd21_proRF_no_bl_24.build.ldscript=linker_scripts/gcc/flash_without_bootloader.ld
samd21_proRF_no_bl_24.build.openocdscript=openocd_scripts/arduino_zero.cfg
samd21_proRF_no_bl_24.build.variant=SparkFun_ProRF
samd21_proRF_no_bl_24.build.variant_system_lib=
samd21_proRF_no_bl_24.build.extra_combine_flags=
samd21_proRF_no_bl_24.build.vid=0x1B4F
samd21_proRF_no_bl_24.build.pid=0x214F
samd21_proRF_no_bl_24.bootloader.tool=openocd
samd21_proRF_no_bl_24.bootloader.file=zero/Sparkfun_SAMD21_ProRF.bin

samd21_proRF_1w.name=SparkFun SAMD21 Pro RF 1W
samd21_proRF_1w.vid.0=0x1B4F
samd21_proRF_1w.pid.0=0x8D21
Expand Down
10 changes: 9 additions & 1 deletion sparkfun/samd/cores/arduino/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ void SystemInit( void )
/* ----------------------------------------------------------------------------------------------
* 5) Switch Generic Clock Generator 0 to DFLL48M. CPU will run at 48MHz.
*/
#if F_CPU != 8000000L

#if F_CPU == 24000000L
GCLK->GENDIV.reg = GCLK_GENDIV_DIV(2) | GCLK_GENDIV_ID( GENERIC_CLOCK_GENERATOR_MAIN ) ; // Generic Clock Generator 0
#else
GCLK->GENDIV.reg = GCLK_GENDIV_ID( GENERIC_CLOCK_GENERATOR_MAIN ) ; // Generic Clock Generator 0
#endif

while ( GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY )
{
Expand All @@ -245,6 +251,7 @@ void SystemInit( void )
{
/* Wait for synchronization */
}
#endif

/* ----------------------------------------------------------------------------------------------
* 6) Modify PRESCaler value of OSC8M to have 8MHz
Expand Down Expand Up @@ -277,7 +284,8 @@ void SystemInit( void )
PM->APBBSEL.reg = PM_APBBSEL_APBBDIV_DIV1_Val ;
PM->APBCSEL.reg = PM_APBCSEL_APBCDIV_DIV1_Val ;

SystemCoreClock=VARIANT_MCK ;
//SystemCoreClock=VARIANT_MCK ;
SystemCoreClock = F_CPU;

/* ----------------------------------------------------------------------------------------------
* 8) Load ADC factory calibration values
Expand Down
4 changes: 2 additions & 2 deletions sparkfun/samd/platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ tools.openocd.erase.pattern=

tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{{runtime.platform.path}/bootloaders/{bootloader.file}}} verify reset; shutdown"
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"

#
# OpenOCD sketch upload - version with configurable bootloader size
Expand All @@ -210,4 +210,4 @@ tools.openocd-withbootsize.erase.pattern=

tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{{runtime.platform.path}/bootloaders/{bootloader.file}}} verify reset; shutdown"
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"