Skip to content

Commit

Permalink
Experimental: Overclock patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Mar 21, 2023
1 parent 480e13d commit e925abd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
env:
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
RELEASE_FILE_WITH_OS: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython-with-badger-os.uf2
FIRMWARE_DIR: "$GITHUB_WORKSPACE/badger2040/firmware"
BOARD_DIR: "$GITHUB_WORKSPACE/badger2040/firmware/${{matrix.board}}"
BADGER_OS_DIR: "$GITHUB_WORKSPACE/badger2040/badger_os"

Expand Down Expand Up @@ -116,6 +117,13 @@ jobs:
ref: v0.0.1
path: dir2uf2

# HACK: Patch startup overclock into Pico SDK
- name: "HACK: Startup Overclock Patch"
shell: bash
working-directory: micropython/lib/pico-sdk
run: |
git apply "${{env.FIRMWARE_DIR}}/startup_overclock.patch"
# Install apt packages
- name: Install CCache & Compiler
shell: bash
Expand Down
26 changes: 26 additions & 0 deletions firmware/startup_overclock.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S
index d061108..864d31f 100644
--- a/src/rp2_common/pico_standard_link/crt0.S
+++ b/src/rp2_common/pico_standard_link/crt0.S
@@ -10,6 +10,8 @@
#include "hardware/regs/sio.h"
#include "pico/asm_helper.S"
#include "pico/binary_info/defs.h"
+#include "hardware/regs/resets.h"
+#include "hardware/regs/rosc.h"

#ifdef NDEBUG
#ifndef COLLAPSE_IRQS
@@ -226,6 +228,12 @@ _reset_handler:
cmp r0, #0
bne hold_non_core0_in_bootrom

+ // Increase ROSC frequency to ~48MHz (range 14.4 - 96)
+ // Speeds up memory zero init and preinit phases.
+ ldr r0, =(ROSC_BASE + ROSC_DIV_OFFSET)
+ ldr r1, =0xaa2
+ str r1, [r0]
+
// In a NO_FLASH binary, don't perform .data copy, since it's loaded
// in-place by the SRAM load. Still need to clear .bss
#if !PICO_NO_FLASH

0 comments on commit e925abd

Please sign in to comment.