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

add Anne Pro 2 bootloader & flashing #16548

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions builddefs/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ ifeq ($(strip $(BOOTLOADER)), md-boot)
OPT_DEFS += -DBOOTLOADER_MD_BOOT
BOOTLOADER_TYPE = md_boot
endif
ifeq ($(strip $(BOOTLOADER)), annepro2)
OPT_DEFS += -DBOOTLOADER_ANNEPRO2
BOOTLOADER_TYPE = annepro2
endif

ifeq ($(strip $(BOOTLOADER_TYPE)),)
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate 'BOOTLOADER' in your keyboard's 'rules.mk' file.)
Expand Down
46 changes: 46 additions & 0 deletions platforms/chibios/bootloaders/annepro2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* Copyright 2021 QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "bootloader.h"

#include <ch.h>
#include "wait.h"
#include "annepro2_ble.h"
#include "ap2_led.h"

#define RAM_MAGIC_LOCATION 0x20001ffc
#define IAP_MAGIC_VALUE 0x0000fab2

__attribute__((weak)) void bootloader_jump(void) {
// Send msg to shine to boot into IAP
annepro2SetIAP();

// wait for shine to boot into IAP
wait_ms(15);

// Load ble into IAP
annepro2_ble_bootload();
wait_ms(15);

// Magic key to set keyboard to IAP
// It’s from reversing original boot loader
// If value is that it stays in boot loader aka IAP
*((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE;

// Load the main MCU into IAP
__disable_irq();
NVIC_SystemReset();
}
13 changes: 13 additions & 0 deletions platforms/chibios/flash.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ define EXEC_WB32_DFU_UPDATER
wb32-dfu-updater_cli -D $(BUILD_DIR)/$(TARGET).bin
endef


define EXEC_FLASH_ANNEPRO2_C15
annepro2_tools $(BUILD_DIR)/$(TARGET).bin
endef

define EXEC_FLASH_ANNEPRO2_C18
annepro2_tools $(BUILD_DIR)/$(TARGET).bin -i=0
endef

dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
$(call EXEC_DFU_UTIL)

Expand Down Expand Up @@ -100,6 +109,10 @@ else ifeq ($(strip $(MCU_FAMILY)),WB32)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_WB32_DFU_UPDATER)
else ifeq ($(strip $(MCU_FAMILY)),GD32V)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
else ifeq ($(strip $(BOARD)),ANNEPRO2_C15)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_FLASH_ANNEPRO2_C15)
else ifeq ($(strip $(BOARD)),ANNEPRO2_C18)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_FLASH_ANNEPRO2_C18)
else
$(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)"
endif