VOOZH about

URL: https://dev.to/amken3d/why-i-wrote-an-entire-rp2350-sdk-in-pure-arm-assembly-2jf5

⇱ Why I wrote an entire RP2350 SDK in pure ARM assembly - DEV Community


This post lives at the canonical source on ticktrace.io. Read it there for the latest version.

Why I wrote an entire RP2350 SDK in pure ARM assembly

ticktrace is a pure-assembly firmware SDK for the Raspberry Pi RP2350. The default blinky is just 1192 bytes. The toolchain you
install to build it is 5.6 MB. No gcc, no newlib, no libstdc++. The most minimalist, yet powerful SDK for the RP2 family.

What pure assembly actually looks like

People hear "assembly" and picture something unreadable. Here is the entire main function of the default firmware. This is the actual source, line for line, from src/main.S:

 .thumb_func
 .global main
main:
 @ ---- Clock tree bring-up ---------------------------------------------
 bl xosc_init @ XOSC stable
 bl pll_sys_150_mhz @ pll_sys = 150 MHz
 bl pll_usb_48_mhz @ pll_usb = 48 MHz
 bl clocks_init @ wire muxes
 bl tick_init @ 1 MHz tick to TIMER0/1/WDG
 bl watchdog_disable @ explicit safe state

 @ ---- Peripheral init at the new clock rate ---------------------------
 bl gpio_led_init @ LED on GP25
 bl uart0_init @ wrong baud (computed for 12 MHz)
 bl clocks_post_pll_uart_baud_fixup @ fix to 150 MHz divisors

 ldr r0, =banner
 bl uart0_puts

.Lloop:
 bl gpio_led_toggle

 @ 3-cycle inner body (subs + bne) at 150 MHz = 20 ns / iteration.
 @ DELAY_COUNT = 12_500_000 -> 250 ms half-period -> ~2 Hz blink.
 ldr r0, =DELAY_COUNT_150MHZ
1: subs r0, #1
 bne 1b

 b .Lloop

Read the full version on the blog.There is also an entire 14 chapter book that walks you through the basics of Assembly on this family of microcontroller.

Repo: github.com/ticktrace-sdk/rp-asm
Site: ticktrace.io
Book: Learning Assembly with ticktrace